mirror of https://github.com/ipxe/ipxe.git
[ecm] Expose USB vendor/device information to ecm_fetch_mac()
Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/467/head
parent
0cc4c42f0a
commit
91e147213c
|
@ -81,13 +81,14 @@ ecm_ethernet_descriptor ( struct usb_configuration_descriptor *config,
|
||||||
/**
|
/**
|
||||||
* Get hardware MAC address
|
* Get hardware MAC address
|
||||||
*
|
*
|
||||||
* @v usb USB device
|
* @v func USB function
|
||||||
* @v desc Ethernet functional descriptor
|
* @v desc Ethernet functional descriptor
|
||||||
* @v hw_addr Hardware address to fill in
|
* @v hw_addr Hardware address to fill in
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
int ecm_fetch_mac ( struct usb_device *usb,
|
int ecm_fetch_mac ( struct usb_function *func,
|
||||||
struct ecm_ethernet_descriptor *desc, uint8_t *hw_addr ) {
|
struct ecm_ethernet_descriptor *desc, uint8_t *hw_addr ) {
|
||||||
|
struct usb_device *usb = func->usb;
|
||||||
char buf[ base16_encoded_len ( ETH_ALEN ) + 1 /* NUL */ ];
|
char buf[ base16_encoded_len ( ETH_ALEN ) + 1 /* NUL */ ];
|
||||||
int len;
|
int len;
|
||||||
int rc;
|
int rc;
|
||||||
|
@ -103,7 +104,7 @@ int ecm_fetch_mac ( struct usb_device *usb,
|
||||||
/* Sanity check */
|
/* Sanity check */
|
||||||
if ( len != ( ( int ) ( sizeof ( buf ) - 1 /* NUL */ ) ) ) {
|
if ( len != ( ( int ) ( sizeof ( buf ) - 1 /* NUL */ ) ) ) {
|
||||||
DBGC ( usb, "USB %s has invalid ECM MAC \"%s\"\n",
|
DBGC ( usb, "USB %s has invalid ECM MAC \"%s\"\n",
|
||||||
usb->name, buf );
|
func->name, buf );
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +113,7 @@ int ecm_fetch_mac ( struct usb_device *usb,
|
||||||
if ( len < 0 ) {
|
if ( len < 0 ) {
|
||||||
rc = len;
|
rc = len;
|
||||||
DBGC ( usb, "USB %s could not decode ECM MAC \"%s\": %s\n",
|
DBGC ( usb, "USB %s could not decode ECM MAC \"%s\": %s\n",
|
||||||
usb->name, buf, strerror ( rc ) );
|
func->name, buf, strerror ( rc ) );
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,7 +465,7 @@ static int ecm_probe ( struct usb_function *func,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fetch MAC address */
|
/* Fetch MAC address */
|
||||||
if ( ( rc = ecm_fetch_mac ( usb, ethernet, netdev->hw_addr ) ) != 0 ) {
|
if ( ( rc = ecm_fetch_mac ( func, ethernet, netdev->hw_addr ) ) != 0 ) {
|
||||||
DBGC ( ecm, "ECM %p could not fetch MAC address: %s\n",
|
DBGC ( ecm, "ECM %p could not fetch MAC address: %s\n",
|
||||||
ecm, strerror ( rc ) );
|
ecm, strerror ( rc ) );
|
||||||
goto err_fetch_mac;
|
goto err_fetch_mac;
|
||||||
|
|
|
@ -86,7 +86,7 @@ struct ecm_device {
|
||||||
extern struct ecm_ethernet_descriptor *
|
extern struct ecm_ethernet_descriptor *
|
||||||
ecm_ethernet_descriptor ( struct usb_configuration_descriptor *config,
|
ecm_ethernet_descriptor ( struct usb_configuration_descriptor *config,
|
||||||
struct usb_interface_descriptor *interface );
|
struct usb_interface_descriptor *interface );
|
||||||
extern int ecm_fetch_mac ( struct usb_device *usb,
|
extern int ecm_fetch_mac ( struct usb_function *func,
|
||||||
struct ecm_ethernet_descriptor *desc,
|
struct ecm_ethernet_descriptor *desc,
|
||||||
uint8_t *hw_addr );
|
uint8_t *hw_addr );
|
||||||
|
|
||||||
|
|
|
@ -598,7 +598,7 @@ static int ncm_probe ( struct usb_function *func,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fetch MAC address */
|
/* Fetch MAC address */
|
||||||
if ( ( rc = ecm_fetch_mac ( usb, ethernet, netdev->hw_addr ) ) != 0 ) {
|
if ( ( rc = ecm_fetch_mac ( func, ethernet, netdev->hw_addr ) ) != 0 ) {
|
||||||
DBGC ( ncm, "NCM %p could not fetch MAC address: %s\n",
|
DBGC ( ncm, "NCM %p could not fetch MAC address: %s\n",
|
||||||
ncm, strerror ( rc ) );
|
ncm, strerror ( rc ) );
|
||||||
goto err_fetch_mac;
|
goto err_fetch_mac;
|
||||||
|
|
Loading…
Reference in New Issue