18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * fs/hmdfs/comm/device_node.h 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef HMDFS_DEVICE_NODE_H 98c2ecf20Sopenharmony_ci#define HMDFS_DEVICE_NODE_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include "hmdfs.h" 128c2ecf20Sopenharmony_ci#include "transport.h" 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_cienum CTRL_NODE_CMD { 158c2ecf20Sopenharmony_ci CMD_UPDATE_SOCKET = 0, 168c2ecf20Sopenharmony_ci CMD_UPDATE_DEVSL, 178c2ecf20Sopenharmony_ci CMD_OFF_LINE, 188c2ecf20Sopenharmony_ci CMD_CNT, 198c2ecf20Sopenharmony_ci}; 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_cistruct update_socket_param { 228c2ecf20Sopenharmony_ci int32_t cmd; 238c2ecf20Sopenharmony_ci int32_t newfd; 248c2ecf20Sopenharmony_ci uint32_t devsl; 258c2ecf20Sopenharmony_ci uint8_t status; 268c2ecf20Sopenharmony_ci uint8_t masterkey[HMDFS_KEY_SIZE]; 278c2ecf20Sopenharmony_ci uint8_t cid[HMDFS_CID_SIZE]; 288c2ecf20Sopenharmony_ci} __packed; 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_cistruct update_devsl_param { 318c2ecf20Sopenharmony_ci int32_t cmd; 328c2ecf20Sopenharmony_ci uint32_t devsl; 338c2ecf20Sopenharmony_ci uint8_t cid[HMDFS_CID_SIZE]; 348c2ecf20Sopenharmony_ci} __attribute__((packed)); 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_cistruct offline_param { 378c2ecf20Sopenharmony_ci int32_t cmd; 388c2ecf20Sopenharmony_ci uint8_t remote_cid[HMDFS_CID_SIZE]; 398c2ecf20Sopenharmony_ci} __packed; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_cistruct offline_all_param { 428c2ecf20Sopenharmony_ci int32_t cmd; 438c2ecf20Sopenharmony_ci} __packed; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cienum NOTIFY { 468c2ecf20Sopenharmony_ci NOTIFY_GET_SESSION, 478c2ecf20Sopenharmony_ci NOTIFY_OFFLINE, 488c2ecf20Sopenharmony_ci NOTIFY_NONE, 498c2ecf20Sopenharmony_ci NOTIFY_CNT, 508c2ecf20Sopenharmony_ci}; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistruct notify_param { 538c2ecf20Sopenharmony_ci int32_t notify; 548c2ecf20Sopenharmony_ci int32_t fd; 558c2ecf20Sopenharmony_ci uint8_t remote_cid[HMDFS_CID_SIZE]; 568c2ecf20Sopenharmony_ci} __packed; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cistruct sbi_attribute { 598c2ecf20Sopenharmony_ci struct attribute attr; 608c2ecf20Sopenharmony_ci ssize_t (*show)(struct kobject *kobj, struct sbi_attribute *attr, 618c2ecf20Sopenharmony_ci char *buf); 628c2ecf20Sopenharmony_ci ssize_t (*store)(struct kobject *kobj, struct sbi_attribute *attr, 638c2ecf20Sopenharmony_ci const char *buf, size_t len); 648c2ecf20Sopenharmony_ci}; 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_cistruct peer_attribute { 678c2ecf20Sopenharmony_ci struct attribute attr; 688c2ecf20Sopenharmony_ci ssize_t (*show)(struct kobject *kobj, struct peer_attribute *attr, 698c2ecf20Sopenharmony_ci char *buf); 708c2ecf20Sopenharmony_ci ssize_t (*store)(struct kobject *kobj, struct peer_attribute *attr, 718c2ecf20Sopenharmony_ci const char *buf, size_t len); 728c2ecf20Sopenharmony_ci}; 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_cistruct sbi_cmd_attribute { 758c2ecf20Sopenharmony_ci struct attribute attr; 768c2ecf20Sopenharmony_ci int command; 778c2ecf20Sopenharmony_ci}; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_civoid notify(struct hmdfs_peer *node, struct notify_param *param); 808c2ecf20Sopenharmony_ciint hmdfs_register_sysfs(const char *name, struct hmdfs_sb_info *sbi); 818c2ecf20Sopenharmony_civoid hmdfs_unregister_sysfs(struct hmdfs_sb_info *sbi); 828c2ecf20Sopenharmony_civoid hmdfs_release_sysfs(struct hmdfs_sb_info *sbi); 838c2ecf20Sopenharmony_ciint hmdfs_register_peer_sysfs(struct hmdfs_sb_info *sbi, 848c2ecf20Sopenharmony_ci struct hmdfs_peer *peer); 858c2ecf20Sopenharmony_civoid hmdfs_release_peer_sysfs(struct hmdfs_peer *peer); 868c2ecf20Sopenharmony_ciint hmdfs_sysfs_init(void); 878c2ecf20Sopenharmony_civoid hmdfs_sysfs_exit(void); 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_cistatic inline struct sbi_attribute *to_sbi_attr(struct attribute *x) 908c2ecf20Sopenharmony_ci{ 918c2ecf20Sopenharmony_ci return container_of(x, struct sbi_attribute, attr); 928c2ecf20Sopenharmony_ci} 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_cistatic inline struct hmdfs_sb_info *to_sbi(struct kobject *x) 958c2ecf20Sopenharmony_ci{ 968c2ecf20Sopenharmony_ci return container_of(x, struct hmdfs_sb_info, kobj); 978c2ecf20Sopenharmony_ci} 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_cistatic inline struct peer_attribute *to_peer_attr(struct attribute *x) 1008c2ecf20Sopenharmony_ci{ 1018c2ecf20Sopenharmony_ci return container_of(x, struct peer_attribute, attr); 1028c2ecf20Sopenharmony_ci} 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_cistatic inline struct hmdfs_peer *to_peer(struct kobject *x) 1058c2ecf20Sopenharmony_ci{ 1068c2ecf20Sopenharmony_ci return container_of(x, struct hmdfs_peer, kobj); 1078c2ecf20Sopenharmony_ci} 1088c2ecf20Sopenharmony_ci#endif 109