diff mbox series

[net-next] liquidio: Added ndo_get_phys_port_id support

Message ID 20180303025910.GA26255@felix-thinkpad.cavium.com
State Rejected, archived
Delegated to: David Miller
Headers show
Series [net-next] liquidio: Added ndo_get_phys_port_id support | expand

Commit Message

Manlunas, Felix March 3, 2018, 2:59 a.m. UTC
From: Intiyaz Basha <intiyaz.basha@cavium.com>

Added support to the ndo_get_phys_port_id() callback to provide
port specific unique id to the netdev layer.

Port id needs to be unique across different liquidio devices in the system.
So used MAC address for port_id.

Usage: cat /sys/class/net/<interface>/phys_port_id

Signed-off-by: Intiyaz Basha <intiyaz.basha@cavium.com>
Acked-by: Derek Chickles <derek.chickles@cavium.com>
Signed-off-by: Felix Manlunas <felix.manlunas@cavium.com>
---
 drivers/net/ethernet/cavium/liquidio/lio_core.c       | 13 +++++++++++++
 drivers/net/ethernet/cavium/liquidio/lio_main.c       |  1 +
 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c    |  1 +
 drivers/net/ethernet/cavium/liquidio/octeon_network.h |  3 +++
 4 files changed, 18 insertions(+)

Comments

David Miller March 5, 2018, 3:23 p.m. UTC | #1
From: Felix Manlunas <felix.manlunas@cavium.com>
Date: Fri, 2 Mar 2018 18:59:10 -0800

> Added support to the ndo_get_phys_port_id() callback to provide
> port specific unique id to the netdev layer.
> 
> Port id needs to be unique across different liquidio devices in the system.
> So used MAC address for port_id.

This doesn't look right at all.

The physical port ID is used in order to distinguish several netdev
devices present on the same PHYSICAL PORT.

So you should be using a number that is unique within a physical
port.

Using the MAC address for this doesn't make any sense at all.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_core.c b/drivers/net/ethernet/cavium/liquidio/lio_core.c
index 8b1ee83..8bb4cfb 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_core.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_core.c
@@ -1081,3 +1081,16 @@  int octeon_setup_interrupt(struct octeon_device *oct, u32 num_ioqs)
 	}
 	return 0;
 }
+
+int liquidio_get_phys_port_id(struct net_device *netdev,
+			      struct netdev_phys_item_id *ppid)
+{
+	struct lio *lio = GET_LIO(netdev);
+	u8 addr[ETH_ALEN];
+
+	u64_to_ether_addr(be64_to_cpu(lio->linfo.hw_addr), addr);
+	ppid->id_len = ETH_ALEN;
+	memcpy(ppid->id, addr, ppid->id_len);
+
+	return 0;
+}
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index a5eecd8..e376b9d 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -3424,6 +3424,7 @@  static const struct net_device_ops lionetdevops = {
 	.ndo_set_vf_vlan	= liquidio_set_vf_vlan,
 	.ndo_get_vf_config	= liquidio_get_vf_config,
 	.ndo_set_vf_link_state  = liquidio_set_vf_link_state,
+	.ndo_get_phys_port_id	= liquidio_get_phys_port_id,
 };
 
 /** \brief Entry point for the liquidio module
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
index fd70a48..dbff977 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
@@ -2244,6 +2244,7 @@  static const struct net_device_ops lionetdevops = {
 	.ndo_set_features	= liquidio_set_features,
 	.ndo_udp_tunnel_add     = liquidio_add_vxlan_port,
 	.ndo_udp_tunnel_del     = liquidio_del_vxlan_port,
+	.ndo_get_phys_port_id	= liquidio_get_phys_port_id,
 };
 
 static int lio_nic_info(struct octeon_recv_info *recv_info, void *buf)
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_network.h b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
index f2d1a07..ea7536f 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_network.h
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
@@ -184,6 +184,9 @@  int octeon_setup_interrupt(struct octeon_device *oct, u32 num_ioqs);
  */
 void liquidio_set_ethtool_ops(struct net_device *netdev);
 
+int liquidio_get_phys_port_id(struct net_device *netdev,
+			      struct netdev_phys_item_id *ppid);
+
 #define SKB_ADJ_MASK  0x3F
 #define SKB_ADJ       (SKB_ADJ_MASK + 1)