From: Sridhar Samudrala <sridhar.samudrala@intel.com>
To: alexander.h.duyck@intel.com, john.r.fastabend@intel.com,
anjali.singhai@intel.com, jakub.kicinski@netronome.com,
davem@davemloft.net, scott.d.peterson@intel.com,
gerlitz.or@gmail.com, jiri@resnulli.us,
intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org
Subject: [next-queue v3 PATCH 7/7] i40e: Add support to get switch id and port number for VFPR netdevs
Date: Mon, 9 Jan 2017 16:59:50 -0800 [thread overview]
Message-ID: <1484009990-3018-8-git-send-email-sridhar.samudrala@intel.com> (raw)
In-Reply-To: <1484009990-3018-1-git-send-email-sridhar.samudrala@intel.com>
Introduce switchdev_ops to PF and VFPR netdevs to return the switch id
via SWITCHDEV_ATTR_ID_PORT_PARENT_ID attribute.
Also, ndo_get_phys_port_name() support is added to VFPR netdevs to
return the port number.
PF: enp5s0f0, VFs: enp5s2,enp5s2f1 VFPRs:enp5s0f0-vf0, enp5s0f0-vf1
# rmmod i40e; modprobe i40e
# devlink dev eswitch set pci/0000:05:00.0 mode switchdev
# echo 2 > /sys/class/net/enp5s0f0/device/sriov_numvfs
# ip -d l show enp5s0f0
32: enp5s0f0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 68:05:ca:2e:72:68 brd ff:ff:ff:ff:ff:ff promiscuity 0 addrgenmode eui64 numtxqueues 72 numrxqueues 72 gso_max_size 65536 gso_max_segs 65535 portid 6805ca2e7268 switchid 6805ca2e7268
vf 0 MAC 00:00:00:00:00:00, spoof checking on, link-state disable, trust off
vf 1 MAC 00:00:00:00:00:00, spoof checking on, link-state disable, trust off
# ip -d l show enp5s0f0-vf0
34: enp5s0f0-vf0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 68:05:ca:2e:72:68 brd ff:ff:ff:ff:ff:ff promiscuity 0 addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 portname 0 switchid 6805ca2e7268
# ip -d l show enp5s0f0-vf1
35: enp5s0f0-vf1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 68:05:ca:2e:72:68 brd ff:ff:ff:ff:ff:ff promiscuity 0 addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 portname 1 switchid 6805ca2e7268
Signed-off-by: Sridhar Samudrala <sridhar.samudrala@intel.com>
---
drivers/net/ethernet/intel/i40e/i40e.h | 1 +
drivers/net/ethernet/intel/i40e/i40e_main.c | 28 +++++++++++++++
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 40 ++++++++++++++++++++++
3 files changed, 69 insertions(+)
diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h
index d038bc1..09346a5 100644
--- a/drivers/net/ethernet/intel/i40e/i40e.h
+++ b/drivers/net/ethernet/intel/i40e/i40e.h
@@ -56,6 +56,7 @@
#include <linux/ptp_clock_kernel.h>
#include <net/devlink.h>
#include <net/dst_metadata.h>
+#include <net/switchdev.h>
#include "i40e_type.h"
#include "i40e_prototype.h"
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index ac324e2..bb41fdc 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -9656,6 +9656,31 @@ static const struct net_device_ops i40e_netdev_ops = {
.ndo_xdp = i40e_xdp,
};
+static int i40e_pf_attr_get(struct net_device *dev, struct switchdev_attr *attr)
+{
+ struct i40e_netdev_priv *np = netdev_priv(dev);
+ struct i40e_vsi *vsi = np->vsi;
+ struct i40e_pf *pf = vsi->back;
+
+ if (pf->eswitch_mode == DEVLINK_ESWITCH_MODE_LEGACY)
+ return -EOPNOTSUPP;
+
+ switch (attr->id) {
+ case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
+ attr->u.ppid.id_len = ETH_ALEN;
+ ether_addr_copy(attr->u.ppid.id, dev->dev_addr);
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+
+ return 0;
+}
+
+static const struct switchdev_ops i40e_pf_switchdev_ops = {
+ .switchdev_port_attr_get = i40e_pf_attr_get,
+};
+
/**
* i40e_config_netdev - Setup the netdev flags
* @vsi: the VSI being configured
@@ -9775,6 +9800,9 @@ static int i40e_config_netdev(struct i40e_vsi *vsi)
#ifdef I40E_FCOE
i40e_fcoe_config_netdev(netdev, vsi);
#endif
+#ifdef CONFIG_NET_SWITCHDEV
+ netdev->switchdev_ops = &i40e_pf_switchdev_ops;
+#endif
/* MTU range: 68 - 9706 */
netdev->min_mtu = ETH_MIN_MTU;
diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 5915280..2f84d70 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -1156,6 +1156,22 @@ i40e_vfpr_netdev_get_offload_stats(int attr_id, const struct net_device *dev,
return -EINVAL;
}
+static int
+i40e_vfpr_netdev_get_phys_port_name(struct net_device *dev, char *buf,
+ size_t len)
+{
+ struct i40e_vfpr_netdev_priv *priv = netdev_priv(dev);
+ struct i40e_vf *vf = priv->vf;
+
+ int ret;
+
+ ret = snprintf(buf, len, "%d", vf->vf_id);
+ if (ret >= len)
+ return -EOPNOTSUPP;
+
+ return 0;
+}
+
static const struct net_device_ops i40e_vfpr_netdev_ops = {
.ndo_open = i40e_vfpr_netdev_open,
.ndo_stop = i40e_vfpr_netdev_stop,
@@ -1163,6 +1179,26 @@ static const struct net_device_ops i40e_vfpr_netdev_ops = {
.ndo_get_stats64 = i40e_vfpr_netdev_get_stats64,
.ndo_has_offload_stats = i40e_vfpr_netdev_has_offload_stats,
.ndo_get_offload_stats = i40e_vfpr_netdev_get_offload_stats,
+ .ndo_get_phys_port_name = i40e_vfpr_netdev_get_phys_port_name,
+};
+
+static int i40e_vfpr_attr_get(struct net_device *dev,
+ struct switchdev_attr *attr)
+{
+ switch (attr->id) {
+ case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
+ attr->u.ppid.id_len = ETH_ALEN;
+ ether_addr_copy(attr->u.ppid.id, dev->dev_addr);
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+
+ return 0;
+}
+
+static const struct switchdev_ops i40e_vfpr_switchdev_ops = {
+ .switchdev_port_attr_get = i40e_vfpr_attr_get,
};
/**
@@ -1237,6 +1273,10 @@ int i40e_alloc_vfpr_netdev(struct i40e_vf *vf, u16 vf_num)
vfpr_netdev->netdev_ops = &i40e_vfpr_netdev_ops;
eth_hw_addr_inherit(vfpr_netdev, vsi->netdev);
+#ifdef CONFIG_NET_SWITCHDEV
+ vfpr_netdev->switchdev_ops = &i40e_vfpr_switchdev_ops;
+#endif
+
netif_carrier_off(vfpr_netdev);
netif_tx_disable(vfpr_netdev);
--
2.5.5
prev parent reply other threads:[~2017-01-10 1:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-10 0:59 [next-queue v3 PATCH 0/7]i40e: Add VF Port Representator support for SR-IOV VFs Sridhar Samudrala
2017-01-10 0:59 ` [next-queue v3 PATCH 1/7] i40e: Introduce devlink interface Sridhar Samudrala
2017-01-10 0:59 ` [next-queue v3 PATCH 2/7] i40e: Introduce VF Port Representator(VFPR) netdevs Sridhar Samudrala
2017-01-10 0:59 ` [next-queue v3 PATCH 3/7] i40e: Sync link state between VFs and VFPRs Sridhar Samudrala
2017-01-10 0:59 ` [next-queue v3 PATCH 4/7] net: store port/representator id in metadata_dst Sridhar Samudrala
2017-01-10 0:59 ` [next-queue v3 PATCH 5/7] i40e: Add TX and RX support in switchdev mode Sridhar Samudrala
2017-01-10 0:59 ` [next-queue v3 PATCH 6/7] i40e: Add support for exposing VF port statistics via VFPR netdev on the host Sridhar Samudrala
2017-01-10 8:37 ` kbuild test robot
2017-01-10 0:59 ` Sridhar Samudrala [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1484009990-3018-8-git-send-email-sridhar.samudrala@intel.com \
--to=sridhar.samudrala@intel.com \
--cc=alexander.h.duyck@intel.com \
--cc=anjali.singhai@intel.com \
--cc=davem@davemloft.net \
--cc=gerlitz.or@gmail.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jakub.kicinski@netronome.com \
--cc=jiri@resnulli.us \
--cc=john.r.fastabend@intel.com \
--cc=netdev@vger.kernel.org \
--cc=scott.d.peterson@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).