diff options
-rw-r--r-- | include/linux/netdevice.h | 20 | ||||
-rw-r--r-- | net/core/dev.c | 18 |
2 files changed, 38 insertions, 0 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 3ca60b070ef0..875f869dc38a 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -728,6 +728,16 @@ struct netdev_fcoe_hbainfo { | |||
728 | }; | 728 | }; |
729 | #endif | 729 | #endif |
730 | 730 | ||
731 | #define MAX_PHYS_PORT_ID_LEN 32 | ||
732 | |||
733 | /* This structure holds a unique identifier to identify the | ||
734 | * physical port used by a netdevice. | ||
735 | */ | ||
736 | struct netdev_phys_port_id { | ||
737 | unsigned char id[MAX_PHYS_PORT_ID_LEN]; | ||
738 | unsigned char id_len; | ||
739 | }; | ||
740 | |||
731 | /* | 741 | /* |
732 | * This structure defines the management hooks for network devices. | 742 | * This structure defines the management hooks for network devices. |
733 | * The following hooks can be defined; unless noted otherwise, they are | 743 | * The following hooks can be defined; unless noted otherwise, they are |
@@ -932,6 +942,12 @@ struct netdev_fcoe_hbainfo { | |||
932 | * that determine carrier state from physical hardware properties (eg | 942 | * that determine carrier state from physical hardware properties (eg |
933 | * network cables) or protocol-dependent mechanisms (eg | 943 | * network cables) or protocol-dependent mechanisms (eg |
934 | * USB_CDC_NOTIFY_NETWORK_CONNECTION) should NOT implement this function. | 944 | * USB_CDC_NOTIFY_NETWORK_CONNECTION) should NOT implement this function. |
945 | * | ||
946 | * int (*ndo_get_phys_port_id)(struct net_device *dev, | ||
947 | * struct netdev_phys_port_id *ppid); | ||
948 | * Called to get ID of physical port of this device. If driver does | ||
949 | * not implement this, it is assumed that the hw is not able to have | ||
950 | * multiple net devices on single physical port. | ||
935 | */ | 951 | */ |
936 | struct net_device_ops { | 952 | struct net_device_ops { |
937 | int (*ndo_init)(struct net_device *dev); | 953 | int (*ndo_init)(struct net_device *dev); |
@@ -1060,6 +1076,8 @@ struct net_device_ops { | |||
1060 | struct nlmsghdr *nlh); | 1076 | struct nlmsghdr *nlh); |
1061 | int (*ndo_change_carrier)(struct net_device *dev, | 1077 | int (*ndo_change_carrier)(struct net_device *dev, |
1062 | bool new_carrier); | 1078 | bool new_carrier); |
1079 | int (*ndo_get_phys_port_id)(struct net_device *dev, | ||
1080 | struct netdev_phys_port_id *ppid); | ||
1063 | }; | 1081 | }; |
1064 | 1082 | ||
1065 | /* | 1083 | /* |
@@ -2315,6 +2333,8 @@ extern int dev_set_mac_address(struct net_device *, | |||
2315 | struct sockaddr *); | 2333 | struct sockaddr *); |
2316 | extern int dev_change_carrier(struct net_device *, | 2334 | extern int dev_change_carrier(struct net_device *, |
2317 | bool new_carrier); | 2335 | bool new_carrier); |
2336 | extern int dev_get_phys_port_id(struct net_device *dev, | ||
2337 | struct netdev_phys_port_id *ppid); | ||
2318 | extern int dev_hard_start_xmit(struct sk_buff *skb, | 2338 | extern int dev_hard_start_xmit(struct sk_buff *skb, |
2319 | struct net_device *dev, | 2339 | struct net_device *dev, |
2320 | struct netdev_queue *txq); | 2340 | struct netdev_queue *txq); |
diff --git a/net/core/dev.c b/net/core/dev.c index dfd9f5d56ae0..58eb802584b9 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -4989,6 +4989,24 @@ int dev_change_carrier(struct net_device *dev, bool new_carrier) | |||
4989 | EXPORT_SYMBOL(dev_change_carrier); | 4989 | EXPORT_SYMBOL(dev_change_carrier); |
4990 | 4990 | ||
4991 | /** | 4991 | /** |
4992 | * dev_get_phys_port_id - Get device physical port ID | ||
4993 | * @dev: device | ||
4994 | * @ppid: port ID | ||
4995 | * | ||
4996 | * Get device physical port ID | ||
4997 | */ | ||
4998 | int dev_get_phys_port_id(struct net_device *dev, | ||
4999 | struct netdev_phys_port_id *ppid) | ||
5000 | { | ||
5001 | const struct net_device_ops *ops = dev->netdev_ops; | ||
5002 | |||
5003 | if (!ops->ndo_get_phys_port_id) | ||
5004 | return -EOPNOTSUPP; | ||
5005 | return ops->ndo_get_phys_port_id(dev, ppid); | ||
5006 | } | ||
5007 | EXPORT_SYMBOL(dev_get_phys_port_id); | ||
5008 | |||
5009 | /** | ||
4992 | * dev_new_index - allocate an ifindex | 5010 | * dev_new_index - allocate an ifindex |
4993 | * @net: the applicable net namespace | 5011 | * @net: the applicable net namespace |
4994 | * | 5012 | * |