1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Export the iSCSI boot info to userland via sysfs. 4 * 5 * Copyright (C) 2010 Red Hat, Inc. All rights reserved. 6 * Copyright (C) 2010 Mike Christie 7 */ 8 #ifndef _ISCSI_BOOT_SYSFS_ 9 #define _ISCSI_BOOT_SYSFS_ 10 11 /* 12 * The text attributes names for each of the kobjects. 13 */ 14 enum iscsi_boot_eth_properties_enum { 15 ISCSI_BOOT_ETH_INDEX, 16 ISCSI_BOOT_ETH_FLAGS, 17 ISCSI_BOOT_ETH_IP_ADDR, 18 ISCSI_BOOT_ETH_PREFIX_LEN, 19 ISCSI_BOOT_ETH_SUBNET_MASK, 20 ISCSI_BOOT_ETH_ORIGIN, 21 ISCSI_BOOT_ETH_GATEWAY, 22 ISCSI_BOOT_ETH_PRIMARY_DNS, 23 ISCSI_BOOT_ETH_SECONDARY_DNS, 24 ISCSI_BOOT_ETH_DHCP, 25 ISCSI_BOOT_ETH_VLAN, 26 ISCSI_BOOT_ETH_MAC, 27 /* eth_pci_bdf - this is replaced by link to the device itself. */ 28 ISCSI_BOOT_ETH_HOSTNAME, 29 ISCSI_BOOT_ETH_END_MARKER, 30 }; 31 32 enum iscsi_boot_tgt_properties_enum { 33 ISCSI_BOOT_TGT_INDEX, 34 ISCSI_BOOT_TGT_FLAGS, 35 ISCSI_BOOT_TGT_IP_ADDR, 36 ISCSI_BOOT_TGT_PORT, 37 ISCSI_BOOT_TGT_LUN, 38 ISCSI_BOOT_TGT_CHAP_TYPE, 39 ISCSI_BOOT_TGT_NIC_ASSOC, 40 ISCSI_BOOT_TGT_NAME, 41 ISCSI_BOOT_TGT_CHAP_NAME, 42 ISCSI_BOOT_TGT_CHAP_SECRET, 43 ISCSI_BOOT_TGT_REV_CHAP_NAME, 44 ISCSI_BOOT_TGT_REV_CHAP_SECRET, 45 ISCSI_BOOT_TGT_END_MARKER, 46 }; 47 48 enum iscsi_boot_initiator_properties_enum { 49 ISCSI_BOOT_INI_INDEX, 50 ISCSI_BOOT_INI_FLAGS, 51 ISCSI_BOOT_INI_ISNS_SERVER, 52 ISCSI_BOOT_INI_SLP_SERVER, 53 ISCSI_BOOT_INI_PRI_RADIUS_SERVER, 54 ISCSI_BOOT_INI_SEC_RADIUS_SERVER, 55 ISCSI_BOOT_INI_INITIATOR_NAME, 56 ISCSI_BOOT_INI_END_MARKER, 57 }; 58 59 enum iscsi_boot_acpitbl_properties_enum { 60 ISCSI_BOOT_ACPITBL_SIGNATURE, 61 ISCSI_BOOT_ACPITBL_OEM_ID, 62 ISCSI_BOOT_ACPITBL_OEM_TABLE_ID, 63 }; 64 65 struct attribute_group; 66 67 struct iscsi_boot_kobj { 68 struct kobject kobj; 69 struct attribute_group *attr_group; 70 struct list_head list; 71 72 /* 73 * Pointer to store driver specific info. If set this will 74 * be freed for the LLD when the kobj release function is called. 75 */ 76 void *data; 77 /* 78 * Driver specific show function. 79 * 80 * The enum of the type. This can be any value of the above 81 * properties. 82 */ 83 ssize_t (*show) (void *data, int type, char *buf); 84 85 /* 86 * Drivers specific visibility function. 87 * The function should return if they the attr should be readable 88 * writable or should not be shown. 89 * 90 * The enum of the type. This can be any value of the above 91 * properties. 92 */ 93 umode_t (*is_visible) (void *data, int type); 94 95 /* 96 * Driver specific release function. 97 * 98 * The function should free the data passed in. 99 */ 100 void (*release) (void *data); 101 }; 102 103 struct iscsi_boot_kset { 104 struct list_head kobj_list; 105 struct kset *kset; 106 }; 107 108 struct iscsi_boot_kobj * 109 iscsi_boot_create_initiator(struct iscsi_boot_kset *boot_kset, int index, 110 void *data, 111 ssize_t (*show) (void *data, int type, char *buf), 112 umode_t (*is_visible) (void *data, int type), 113 void (*release) (void *data)); 114 115 struct iscsi_boot_kobj * 116 iscsi_boot_create_ethernet(struct iscsi_boot_kset *boot_kset, int index, 117 void *data, 118 ssize_t (*show) (void *data, int type, char *buf), 119 umode_t (*is_visible) (void *data, int type), 120 void (*release) (void *data)); 121 struct iscsi_boot_kobj * 122 iscsi_boot_create_target(struct iscsi_boot_kset *boot_kset, int index, 123 void *data, 124 ssize_t (*show) (void *data, int type, char *buf), 125 umode_t (*is_visible) (void *data, int type), 126 void (*release) (void *data)); 127 128 struct iscsi_boot_kobj * 129 iscsi_boot_create_acpitbl(struct iscsi_boot_kset *boot_kset, int index, 130 void *data, 131 ssize_t (*show)(void *data, int type, char *buf), 132 umode_t (*is_visible)(void *data, int type), 133 void (*release)(void *data)); 134 135 struct iscsi_boot_kset *iscsi_boot_create_kset(const char *set_name); 136 struct iscsi_boot_kset *iscsi_boot_create_host_kset(unsigned int hostno); 137 void iscsi_boot_destroy_kset(struct iscsi_boot_kset *boot_kset); 138 139 #endif 140