Explorar el Código

[netdevice] Add "hwaddr" setting

Expose the underlying hardware address as a setting.  For IPoIB
devices, this provides scripts with access to the Infiniband GUID.

Requested-by: Allen, Benjamin S. <bsallen@alcf.anl.gov>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown hace 6 años
padre
commit
8047baf7c6
Se han modificado 1 ficheros con 30 adiciones y 5 borrados
  1. 30
    5
      src/net/netdev_settings.c

+ 30
- 5
src/net/netdev_settings.c Ver fichero

45
 	.description = "MAC address",
45
 	.description = "MAC address",
46
 	.type = &setting_type_hex,
46
 	.type = &setting_type_hex,
47
 };
47
 };
48
+const struct setting hwaddr_setting __setting ( SETTING_NETDEV, hwaddr ) = {
49
+	.name = "hwaddr",
50
+	.description = "Hardware address",
51
+	.type = &setting_type_hex,
52
+};
48
 const struct setting bustype_setting __setting ( SETTING_NETDEV, bustype ) = {
53
 const struct setting bustype_setting __setting ( SETTING_NETDEV, bustype ) = {
49
 	.name = "bustype",
54
 	.name = "bustype",
50
 	.description = "Bus type",
55
 	.description = "Bus type",
78
 };
83
 };
79
 
84
 
80
 /**
85
 /**
81
- * Store MAC address setting
86
+ * Store link-layer address setting
82
  *
87
  *
83
  * @v netdev		Network device
88
  * @v netdev		Network device
84
  * @v data		Setting data, or NULL to clear setting
89
  * @v data		Setting data, or NULL to clear setting
103
 }
108
 }
104
 
109
 
105
 /**
110
 /**
106
- * Fetch MAC address setting
111
+ * Fetch link-layer address setting
107
  *
112
  *
108
  * @v netdev		Network device
113
  * @v netdev		Network device
109
  * @v data		Buffer to fill with setting data
114
  * @v data		Buffer to fill with setting data
112
  */
117
  */
113
 static int netdev_fetch_mac ( struct net_device *netdev, void *data,
118
 static int netdev_fetch_mac ( struct net_device *netdev, void *data,
114
 			      size_t len ) {
119
 			      size_t len ) {
120
+	size_t max_len = netdev->ll_protocol->ll_addr_len;
115
 
121
 
116
-	if ( len > netdev->ll_protocol->ll_addr_len )
117
-		len = netdev->ll_protocol->ll_addr_len;
122
+	if ( len > max_len )
123
+		len = max_len;
118
 	memcpy ( data, netdev->ll_addr, len );
124
 	memcpy ( data, netdev->ll_addr, len );
119
-	return netdev->ll_protocol->ll_addr_len;
125
+	return max_len;
126
+}
127
+
128
+/**
129
+ * Fetch hardware address setting
130
+ *
131
+ * @v netdev		Network device
132
+ * @v data		Buffer to fill with setting data
133
+ * @v len		Length of buffer
134
+ * @ret len		Length of setting data, or negative error
135
+ */
136
+static int netdev_fetch_hwaddr ( struct net_device *netdev, void *data,
137
+				 size_t len ) {
138
+	size_t max_len = netdev->ll_protocol->hw_addr_len;
139
+
140
+	if ( len > max_len )
141
+		len = max_len;
142
+	memcpy ( data, netdev->hw_addr, len );
143
+	return max_len;
120
 }
144
 }
121
 
145
 
122
 /**
146
 /**
253
 /** Network device settings */
277
 /** Network device settings */
254
 static struct netdev_setting_operation netdev_setting_operations[] = {
278
 static struct netdev_setting_operation netdev_setting_operations[] = {
255
 	{ &mac_setting, netdev_store_mac, netdev_fetch_mac },
279
 	{ &mac_setting, netdev_store_mac, netdev_fetch_mac },
280
+	{ &hwaddr_setting, NULL, netdev_fetch_hwaddr },
256
 	{ &bustype_setting, NULL, netdev_fetch_bustype },
281
 	{ &bustype_setting, NULL, netdev_fetch_bustype },
257
 	{ &busloc_setting, NULL, netdev_fetch_busloc },
282
 	{ &busloc_setting, NULL, netdev_fetch_busloc },
258
 	{ &busid_setting, NULL, netdev_fetch_busid },
283
 	{ &busid_setting, NULL, netdev_fetch_busid },

Loading…
Cancelar
Guardar