netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] liquidio: Added ndo_get_phys_port_id support
@ 2018-03-03  2:59 Felix Manlunas
  2018-03-05 15:23 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Felix Manlunas @ 2018-03-03  2:59 UTC (permalink / raw)
  To: davem
  Cc: netdev, raghu.vatsavayi, derek.chickles, satananda.burla,
	intiyaz.basha

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(+)

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)
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] liquidio: Added ndo_get_phys_port_id support
  2018-03-03  2:59 [PATCH net-next] liquidio: Added ndo_get_phys_port_id support Felix Manlunas
@ 2018-03-05 15:23 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-03-05 15:23 UTC (permalink / raw)
  To: felix.manlunas
  Cc: netdev, raghu.vatsavayi, derek.chickles, satananda.burla,
	intiyaz.basha

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-05 15:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-03  2:59 [PATCH net-next] liquidio: Added ndo_get_phys_port_id support Felix Manlunas
2018-03-05 15:23 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).