All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 net-next 0/3] Add option to specify PF parameter for IFLA_VF_MAC
@ 2016-06-30 15:34 Hariprasad Shenai
  2016-06-30 15:34 ` [PATCHv2 net-next 1/3] net: Add provision to specify pf number while assigning VF mac Hariprasad Shenai
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Hariprasad Shenai @ 2016-06-30 15:34 UTC (permalink / raw)
  To: davem, stephen; +Cc: netdev, nirranjan, leedom, kumaras, Hariprasad Shenai

Hi,

We're struggling to implement the PCI SR-IOV management features for
administering Virtual Functions which represent networking devices using
the current Linux APIs. The problem is that these APIs incorporate all
sorts of assumptions which don't match chelsio networking cards.

For instance, the current APIs assume a 1-to-1 mapping of Network Ports,
Physical Functions and the SR-IOV Virtual Functions of those Physical
Functions. This is not the case with our cards where any Virtual Function
can be hooked up to any Port -- or any number of Ports the current Linux
APIs also assume only 1 Network Interface/Port can be accessed per Virtuali
Function.

Another issue is that these APIs assume that the Administrative Driver is
attached to the Physical Function Associated with a Virtual Function. This
is not the case with our card where all administration is performed by a
Driver which is not attached to any of the Physical Functions which have
SR-IOV PCI Capabilities.

Another consequence of these assumptions is the inability to utilize all
of the cards SR-IOV resources. For instance, our cards have SR-IOV
Capabilities on Physical Functions 0..3 and the administrative Driver
attaches to Physical Function 4. Each of the Physical Functions 0..3 can
support up to 16 Virtual Functions. With the current Linux APIs, a 2-Port
card would only be able to use the Virtual Functions on Physical
Function 0..1 and not allow the Virtual Functions on Physical
Functions 2..3 to be used since there are no Ports 2..3 on a 2-Port card.

To start with we have just modified the code to add support for
ndo_set_vf_mac to work with chelsio adapter. And once this gets merged,
will submit patches for reset of the IFLA_VF API's. 

This patch 1/3 and 2/3 has been created against net-next tree, and
patch 3/3 has been created against iproute2 tree.

We have included all the maintainers of respective drivers. Kindly review
the change and let us know in case of any review comments.

Thanks

V2:
  Fixed check for MAC address in Patch 2/3, based on review comments by
  Yuval Mintz <Yuval.Mintz@qlogic.com>

Hariprasad Shenai (2):
  net: Add provision to specify pf number while assigning VF mac
  cxgb4/cxgb4vf: Add set VF mac address support

 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h    |    2 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c  |    2 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c    |    2 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h    |    2 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h         |    3 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c    |   32 ++++++++++-
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c         |   42 +++++++++++++
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c    |   24 ++++++++
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h |    3 +
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c     |   63 ++++++++++++++++++--
 drivers/net/ethernet/cisco/enic/enic_main.c        |    2 +-
 drivers/net/ethernet/emulex/benet/be_main.c        |    2 +-
 drivers/net/ethernet/intel/fm10k/fm10k.h           |    3 +-
 drivers/net/ethernet/intel/fm10k/fm10k_iov.c       |    3 +-
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c |    2 +-
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h |    2 +-
 drivers/net/ethernet/intel/igb/igb_main.c          |    6 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c     |    2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h     |    3 +-
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c     |    3 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  |    2 +-
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov.h  |    2 +-
 .../net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c   |    2 +-
 drivers/net/ethernet/sfc/sriov.c                   |    3 +-
 drivers/net/ethernet/sfc/sriov.h                   |    3 +-
 include/linux/netdevice.h                          |    2 +-
 include/uapi/linux/if_link.h                       |    1 +
 net/core/rtnetlink.c                               |    4 +-
 28 files changed, 192 insertions(+), 30 deletions(-)

Hariprasad Shenai (1):
  ip: Add option to specify PF number associated with the VF

 include/linux/if_link.h |    1 +
 ip/ipaddress.c          |    3 +++
 ip/iplink.c             |   21 ++++++++++++++-------
 man/man8/ip-link.8.in   |   15 +++++++++++++--
 4 files changed, 31 insertions(+), 9 deletions(-)

-- 
1.7.3

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

* [PATCHv2 net-next 1/3] net: Add provision to specify pf number while assigning VF mac
  2016-06-30 15:34 [PATCHv2 net-next 0/3] Add option to specify PF parameter for IFLA_VF_MAC Hariprasad Shenai
@ 2016-06-30 15:34 ` Hariprasad Shenai
  2016-06-30 19:04   ` Yuval Mintz
  2016-06-30 15:34 ` [PATCHv2 net-next 2/3] cxgb4/cxgb4vf: Add set VF mac address support Hariprasad Shenai
  2016-06-30 15:34 ` [PATCHv2 net-next iproute2 3/3] ip: Add option to specify PF number associated with the VF Hariprasad Shenai
  2 siblings, 1 reply; 7+ messages in thread
From: Hariprasad Shenai @ 2016-06-30 15:34 UTC (permalink / raw)
  To: davem, stephen; +Cc: netdev, nirranjan, leedom, kumaras, Hariprasad Shenai

Chelsio T4/T5 cards have SR-IOV Capabilities on Physical Functions
0..3 and the administrative Driver(cxgb4) attaches to Physical Function 4.
Each of the Physical Functions 0..3 can support up to 16 Virtual
Functions. With the current Linux APIs, a 2-Port card would only be
able to use the Virtual Functions on Physical Functions 0..1 and not
allow the Virtual Functions on Physical Functions 2..3 to be used since
there are no Ports 2..3 on a 2-Port card.

Also the current ip commands takes netdev as one of the argument, and
it assumes a 1-to-1 mapping of Network Ports, Physical Functions and the
SR-IOV Virtual Functions of those Physical Functions. But it is not
true in our case and won't work for us.

Added a new argument to specify the PF number associated with the VF, to
fix this.

Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h    |    2 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c  |    2 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c    |    2 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h    |    2 +-
 drivers/net/ethernet/cisco/enic/enic_main.c        |    2 +-
 drivers/net/ethernet/emulex/benet/be_main.c        |    2 +-
 drivers/net/ethernet/intel/fm10k/fm10k.h           |    3 ++-
 drivers/net/ethernet/intel/fm10k/fm10k_iov.c       |    3 ++-
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c |    2 +-
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h |    2 +-
 drivers/net/ethernet/intel/igb/igb_main.c          |    6 ++++--
 drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c     |    2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h     |    3 ++-
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c     |    3 ++-
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  |    2 +-
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov.h  |    2 +-
 .../net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c   |    2 +-
 drivers/net/ethernet/sfc/sriov.c                   |    3 ++-
 drivers/net/ethernet/sfc/sriov.h                   |    3 ++-
 include/linux/netdevice.h                          |    2 +-
 include/uapi/linux/if_link.h                       |    1 +
 net/core/rtnetlink.c                               |    4 ++--
 22 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
index 0e68fad..bc8560b 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
@@ -491,7 +491,7 @@ int __bnx2x_setup_tc(struct net_device *dev, u32 handle, __be16 proto,
 
 int bnx2x_get_vf_config(struct net_device *dev, int vf,
 			struct ifla_vf_info *ivi);
-int bnx2x_set_vf_mac(struct net_device *dev, int queue, u8 *mac);
+int bnx2x_set_vf_mac(struct net_device *dev, int pf, int queue, u8 *mac);
 int bnx2x_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos);
 
 /* select_queue callback */
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
index 632daff..2342daa 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
@@ -2664,7 +2664,7 @@ int bnx2x_get_vf_config(struct net_device *dev, int vfidx,
  * mac configuration request, the PF will simply fail the request and VF can try
  * again after consulting its bulletin board.
  */
-int bnx2x_set_vf_mac(struct net_device *dev, int vfidx, u8 *mac)
+int bnx2x_set_vf_mac(struct net_device *dev, int pf, int vfidx, u8 *mac)
 {
 	struct bnx2x *bp = netdev_priv(dev);
 	int rc, q_logical_state;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
index 50d2007..7d0a318 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
@@ -107,7 +107,7 @@ int bnxt_get_vf_config(struct net_device *dev, int vf_id,
 	return 0;
 }
 
-int bnxt_set_vf_mac(struct net_device *dev, int vf_id, u8 *mac)
+int bnxt_set_vf_mac(struct net_device *dev, int pf, int vf_id, u8 *mac)
 {
 	struct hwrm_func_cfg_input req = {0};
 	struct bnxt *bp = netdev_priv(dev);
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h
index 0392670..a44e7b2 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h
@@ -11,7 +11,7 @@
 #define BNXT_SRIOV_H
 
 int bnxt_get_vf_config(struct net_device *, int, struct ifla_vf_info *);
-int bnxt_set_vf_mac(struct net_device *, int, u8 *);
+int bnxt_set_vf_mac(struct net_device *, int, int, u8 *);
 int bnxt_set_vf_vlan(struct net_device *, int, u16, u8);
 int bnxt_set_vf_bw(struct net_device *, int, int, int);
 int bnxt_set_vf_link_state(struct net_device *, int, int);
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index f15560a..7d70eb9 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -877,7 +877,7 @@ static void enic_tx_timeout(struct net_device *netdev)
 	schedule_work(&enic->tx_hang_reset);
 }
 
-static int enic_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
+static int enic_set_vf_mac(struct net_device *netdev, int pf, int vf, u8 *mac)
 {
 	struct enic *enic = netdev_priv(netdev);
 	struct enic_port_profile *pp;
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 2451a47..b6d9d25 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -1581,7 +1581,7 @@ static void be_set_rx_mode(struct net_device *netdev)
 	be_set_mc_list(adapter);
 }
 
-static int be_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
+static int be_set_vf_mac(struct net_device *netdev, int pf, int vf, u8 *mac)
 {
 	struct be_adapter *adapter = netdev_priv(netdev);
 	struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf];
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k.h b/drivers/net/ethernet/intel/fm10k/fm10k.h
index fcf106e..9b4f62b 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k.h
+++ b/drivers/net/ethernet/intel/fm10k/fm10k.h
@@ -505,7 +505,8 @@ int fm10k_iov_resume(struct pci_dev *pdev);
 void fm10k_iov_disable(struct pci_dev *pdev);
 int fm10k_iov_configure(struct pci_dev *pdev, int num_vfs);
 s32 fm10k_iov_update_pvid(struct fm10k_intfc *interface, u16 glort, u16 pvid);
-int fm10k_ndo_set_vf_mac(struct net_device *netdev, int vf_idx, u8 *mac);
+int fm10k_ndo_set_vf_mac(struct net_device *netdev, int pf,
+			 int vf_idx, u8 *mac);
 int fm10k_ndo_set_vf_vlan(struct net_device *netdev,
 			  int vf_idx, u16 vid, u8 qos);
 int fm10k_ndo_set_vf_bw(struct net_device *netdev, int vf_idx, int rate,
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_iov.c b/drivers/net/ethernet/intel/fm10k/fm10k_iov.c
index 47f0743..060a543 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_iov.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_iov.c
@@ -421,7 +421,8 @@ static inline void fm10k_reset_vf_info(struct fm10k_intfc *interface,
 	fm10k_mbx_unlock(interface);
 }
 
-int fm10k_ndo_set_vf_mac(struct net_device *netdev, int vf_idx, u8 *mac)
+int fm10k_ndo_set_vf_mac(struct net_device *netdev, int pf,
+			 int vf_idx, u8 *mac)
 {
 	struct fm10k_intfc *interface = netdev_priv(netdev);
 	struct fm10k_iov_data *iov_data = interface->iov_data;
diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 1fcafcf..1d6b289 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -2661,7 +2661,7 @@ int i40e_vc_process_vflr_event(struct i40e_pf *pf)
  *
  * program VF mac address
  **/
-int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
+int i40e_ndo_set_vf_mac(struct net_device *netdev, int pf, int vf_id, u8 *mac)
 {
 	struct i40e_netdev_priv *np = netdev_priv(netdev);
 	struct i40e_vsi *vsi = np->vsi;
diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h
index 8751741..9ff6bf3 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h
@@ -128,7 +128,7 @@ void i40e_reset_vf(struct i40e_vf *vf, bool flr);
 void i40e_vc_notify_vf_reset(struct i40e_vf *vf);
 
 /* VF configuration related iplink handlers */
-int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac);
+int i40e_ndo_set_vf_mac(struct net_device *netdev, int pf, int vf_id, u8 *mac);
 int i40e_ndo_set_vf_port_vlan(struct net_device *netdev,
 			      int vf_id, u16 vlan_id, u8 qos);
 int i40e_ndo_set_vf_bw(struct net_device *netdev, int vf_id, int min_tx_rate,
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index ef3d642..3b2af00 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -167,7 +167,8 @@ static void igb_msg_task(struct igb_adapter *);
 static void igb_vmm_control(struct igb_adapter *);
 static int igb_set_vf_mac(struct igb_adapter *, int, unsigned char *);
 static void igb_restore_vf_multicasts(struct igb_adapter *adapter);
-static int igb_ndo_set_vf_mac(struct net_device *netdev, int vf, u8 *mac);
+static int igb_ndo_set_vf_mac(struct net_device *netdev,
+			      int pf, int vf, u8 *mac);
 static int igb_ndo_set_vf_vlan(struct net_device *netdev,
 			       int vf, u16 vlan, u8 qos);
 static int igb_ndo_set_vf_bw(struct net_device *, int, int, int);
@@ -7942,7 +7943,8 @@ static int igb_set_vf_mac(struct igb_adapter *adapter,
 	return 0;
 }
 
-static int igb_ndo_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
+static int igb_ndo_set_vf_mac(struct net_device *netdev,
+			      int pf, int vf, u8 *mac)
 {
 	struct igb_adapter *adapter = netdev_priv(netdev);
 	if (!is_valid_ether_addr(mac) || (vf >= adapter->vfs_allocated_count))
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
index c5caacd..2a39e6e 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
@@ -1277,7 +1277,7 @@ void ixgbe_ping_all_vfs(struct ixgbe_adapter *adapter)
 	}
 }
 
-int ixgbe_ndo_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
+int ixgbe_ndo_set_vf_mac(struct net_device *netdev, int pf, int vf, u8 *mac)
 {
 	struct ixgbe_adapter *adapter = netdev_priv(netdev);
 	if (!is_valid_ether_addr(mac) || (vf >= adapter->num_vfs))
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h
index 47e65e2..eaafbd3 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h
@@ -41,7 +41,8 @@ void ixgbe_msg_task(struct ixgbe_adapter *adapter);
 int ixgbe_vf_configuration(struct pci_dev *pdev, unsigned int event_mask);
 void ixgbe_disable_tx_rx(struct ixgbe_adapter *adapter);
 void ixgbe_ping_all_vfs(struct ixgbe_adapter *adapter);
-int ixgbe_ndo_set_vf_mac(struct net_device *netdev, int queue, u8 *mac);
+int ixgbe_ndo_set_vf_mac(struct net_device *netdev,
+			 int pf, int queue, u8 *mac);
 int ixgbe_ndo_set_vf_vlan(struct net_device *netdev, int queue, u16 vlan,
 			   u8 qos);
 int ixgbe_link_mbps(struct ixgbe_adapter *adapter);
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 973391b..acf1b70 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -2259,7 +2259,8 @@ static int mlx4_en_set_features(struct net_device *netdev,
 	return 0;
 }
 
-static int mlx4_en_set_vf_mac(struct net_device *dev, int queue, u8 *mac)
+static int mlx4_en_set_vf_mac(struct net_device *dev,
+			      int pf, int queue, u8 *mac)
 {
 	struct mlx4_en_priv *en_priv = netdev_priv(dev);
 	struct mlx4_en_dev *mdev = en_priv->mdev;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index f5c8d5d..7ae99bd 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -2431,7 +2431,7 @@ static int mlx5e_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 	}
 }
 
-static int mlx5e_set_vf_mac(struct net_device *dev, int vf, u8 *mac)
+static int mlx5e_set_vf_mac(struct net_device *dev, int pf, int vf, u8 *mac)
 {
 	struct mlx5e_priv *priv = netdev_priv(dev);
 	struct mlx5_core_dev *mdev = priv->mdev;
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov.h
index 017d8c2c..ef39d70 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov.h
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov.h
@@ -233,7 +233,7 @@ bool qlcnic_sriov_soft_flr_check(struct qlcnic_adapter *,
 				 struct qlcnic_vf_info *);
 void qlcnic_sriov_pf_reset(struct qlcnic_adapter *);
 int qlcnic_sriov_pf_reinit(struct qlcnic_adapter *);
-int qlcnic_sriov_set_vf_mac(struct net_device *, int, u8 *);
+int qlcnic_sriov_set_vf_mac(struct net_device *, int, int, u8 *);
 int qlcnic_sriov_set_vf_tx_rate(struct net_device *, int, int, int);
 int qlcnic_sriov_get_vf_config(struct net_device *, int ,
 			       struct ifla_vf_info *);
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c
index afd687e..d7cc7a7 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c
@@ -1802,7 +1802,7 @@ int qlcnic_sriov_pf_reinit(struct qlcnic_adapter *adapter)
 	return err;
 }
 
-int qlcnic_sriov_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
+int qlcnic_sriov_set_vf_mac(struct net_device *netdev, int pf, int vf, u8 *mac)
 {
 	struct qlcnic_adapter *adapter = netdev_priv(netdev);
 	struct qlcnic_sriov *sriov = adapter->ahw->sriov;
diff --git a/drivers/net/ethernet/sfc/sriov.c b/drivers/net/ethernet/sfc/sriov.c
index 816c446..d20edd0 100644
--- a/drivers/net/ethernet/sfc/sriov.c
+++ b/drivers/net/ethernet/sfc/sriov.c
@@ -11,7 +11,8 @@
 #include "nic.h"
 #include "sriov.h"
 
-int efx_sriov_set_vf_mac(struct net_device *net_dev, int vf_i, u8 *mac)
+int efx_sriov_set_vf_mac(struct net_device *net_dev,
+			 int pf, int vf_i, u8 *mac)
 {
 	struct efx_nic *efx = netdev_priv(net_dev);
 
diff --git a/drivers/net/ethernet/sfc/sriov.h b/drivers/net/ethernet/sfc/sriov.h
index 400df52..a8c8b7b 100644
--- a/drivers/net/ethernet/sfc/sriov.h
+++ b/drivers/net/ethernet/sfc/sriov.h
@@ -14,7 +14,8 @@
 
 #ifdef CONFIG_SFC_SRIOV
 
-int efx_sriov_set_vf_mac(struct net_device *net_dev, int vf_i, u8 *mac);
+int efx_sriov_set_vf_mac(struct net_device *net_dev,
+			 int pf, int vf_i, u8 *mac);
 int efx_sriov_set_vf_vlan(struct net_device *net_dev, int vf_i, u16 vlan,
 			  u8 qos);
 int efx_sriov_set_vf_spoofchk(struct net_device *net_dev, int vf_i,
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 890158e..78c14bf 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1148,7 +1148,7 @@ struct net_device_ops {
 	int			(*ndo_busy_poll)(struct napi_struct *dev);
 #endif
 	int			(*ndo_set_vf_mac)(struct net_device *dev,
-						  int queue, u8 *mac);
+						  int pf, int queue, u8 *mac);
 	int			(*ndo_set_vf_vlan)(struct net_device *dev,
 						   int queue, u16 vlan, u8 qos);
 	int			(*ndo_set_vf_rate)(struct net_device *dev,
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index bb36bd5..bc9ef4e 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -633,6 +633,7 @@ enum {
 #define IFLA_VF_MAX (__IFLA_VF_MAX - 1)
 
 struct ifla_vf_mac {
+	__u32 pf;
 	__u32 vf;
 	__u8 mac[32]; /* MAX_ADDR_LEN */
 };
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index eb49ca2..b75b15c 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1643,8 +1643,8 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr **tb)
 
 		err = -EOPNOTSUPP;
 		if (ops->ndo_set_vf_mac)
-			err = ops->ndo_set_vf_mac(dev, ivm->vf,
-						  ivm->mac);
+			err = ops->ndo_set_vf_mac(dev, ivm->pf,
+						  ivm->vf, ivm->mac);
 		if (err < 0)
 			return err;
 	}
-- 
1.7.3

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

* [PATCHv2 net-next 2/3] cxgb4/cxgb4vf: Add set VF mac address support
  2016-06-30 15:34 [PATCHv2 net-next 0/3] Add option to specify PF parameter for IFLA_VF_MAC Hariprasad Shenai
  2016-06-30 15:34 ` [PATCHv2 net-next 1/3] net: Add provision to specify pf number while assigning VF mac Hariprasad Shenai
@ 2016-06-30 15:34 ` Hariprasad Shenai
  2016-06-30 15:34 ` [PATCHv2 net-next iproute2 3/3] ip: Add option to specify PF number associated with the VF Hariprasad Shenai
  2 siblings, 0 replies; 7+ messages in thread
From: Hariprasad Shenai @ 2016-06-30 15:34 UTC (permalink / raw)
  To: davem, stephen; +Cc: netdev, nirranjan, leedom, kumaras, Hariprasad Shenai

Add ndo_set_vf_mac support which allows to set the MAC address
for cxgb4vf interfaces from the host.

Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h         |    3 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c    |   32 ++++++++++-
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c         |   42 +++++++++++++
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c    |   24 ++++++++
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h |    3 +
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c     |   63 ++++++++++++++++++--
 6 files changed, 160 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index b4fceb9..f38735f 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -1520,4 +1520,7 @@ void t4_idma_monitor_init(struct adapter *adapter,
 void t4_idma_monitor(struct adapter *adapter,
 		     struct sge_idma_monitor_state *idma,
 		     int hz, int ticks);
+int t4_set_vf_mac_acl(struct adapter *adapter, unsigned int pf, unsigned int vf,
+		      unsigned int naddr, u8 *addr);
+
 #endif /* __CXGB4_H__ */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index c45de49..da8a444 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3078,6 +3078,34 @@ static int cxgb_change_mtu(struct net_device *dev, int new_mtu)
 	return ret;
 }
 
+#ifdef CONFIG_PCI_IOV
+#define CXGB_PF_WITH_VF 4
+
+static int cxgb_set_vf_mac(struct net_device *dev, int pf, int vf, u8 *mac)
+{
+	struct port_info *pi = netdev_priv(dev);
+
+	/* validate the request */
+	if (pf >= CXGB_PF_WITH_VF) {
+		dev_err(pi->adapter->pdev_dev,
+			"Invalid PF Identifier %d\n", pf);
+		return -EINVAL;
+	}
+
+	/* verify MAC addr is valid */
+	if (!is_valid_ether_addr(mac)) {
+		dev_err(pi->adapter->pdev_dev,
+			"Invalid Ethernet address %pM for PF %d VF %d\n",
+			mac, pf, vf);
+		return -EINVAL;
+	}
+
+	dev_info(pi->adapter->pdev_dev,
+		 "Setting MAC %pM on PF %d VF %d\n", mac, pf, vf);
+	return t4_set_vf_mac_acl(pi->adapter, pf, vf + 1, 1, mac);
+}
+#endif
+
 static int cxgb_set_mac_addr(struct net_device *dev, void *p)
 {
 	int ret;
@@ -3136,7 +3164,9 @@ static const struct net_device_ops cxgb4_netdev_ops = {
 #ifdef CONFIG_NET_RX_BUSY_POLL
 	.ndo_busy_poll        = cxgb_busy_poll,
 #endif
-
+#ifdef CONFIG_PCI_IOV
+	.ndo_set_vf_mac       = cxgb_set_vf_mac,
+#endif
 };
 
 void t4_fatal_err(struct adapter *adap)
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index a63addb..a92e74a 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -8262,3 +8262,45 @@ void t4_idma_monitor(struct adapter *adapter,
 		t4_sge_decode_idma_state(adapter, idma->idma_state[i]);
 	}
 }
+
+/**
+ *	t4_set_vf_mac - Set MAC address for the specified VF
+ *	@adapter: The adapter
+ *	@pf: the PF
+ *	@vf: one of the VFs instantiated by the specified PF
+ *	@naddr: the number of MAC addresses
+ *	@addr: the MAC address(es) to be set to the specified VF
+ */
+int t4_set_vf_mac_acl(struct adapter *adapter, unsigned int pf, unsigned int vf,
+		      unsigned int naddr, u8 *addr)
+{
+	struct fw_acl_mac_cmd cmd;
+
+	memset(&cmd, 0, sizeof(cmd));
+	cmd.op_to_vfn = cpu_to_be32(FW_CMD_OP_V(FW_ACL_MAC_CMD) |
+				    FW_CMD_REQUEST_F |
+				    FW_CMD_WRITE_F |
+				    FW_ACL_MAC_CMD_PFN_V(pf) |
+				    FW_ACL_MAC_CMD_VFN_V(vf));
+
+	/* Note: Do not enable the ACL */
+	cmd.en_to_len16 = cpu_to_be32((unsigned int)FW_LEN16(cmd));
+	cmd.nmac = naddr;
+
+	switch (pf) {
+	case 3:
+		memcpy(cmd.macaddr3, addr, sizeof(cmd.macaddr3));
+		break;
+	case 2:
+		memcpy(cmd.macaddr2, addr, sizeof(cmd.macaddr2));
+		break;
+	case 1:
+		memcpy(cmd.macaddr1, addr, sizeof(cmd.macaddr1));
+		break;
+	case 0:
+		memcpy(cmd.macaddr0, addr, sizeof(cmd.macaddr0));
+		break;
+	}
+
+	return t4_wr_mbox(adapter, adapter->mbox, &cmd, sizeof(cmd), &cmd);
+}
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
index 8d9b2cb..eadf9b1 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
@@ -2695,6 +2695,7 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,
 	struct adapter *adapter;
 	struct port_info *pi;
 	struct net_device *netdev;
+	unsigned int pf;
 
 	/*
 	 * Print our driver banner the first time we're called to initialize a
@@ -2819,8 +2820,11 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,
 	 * Allocate our "adapter ports" and stitch everything together.
 	 */
 	pmask = adapter->params.vfres.pmask;
+	pf = t4vf_get_pf_from_vf(adapter); 
 	for_each_port(adapter, pidx) {
 		int port_id, viid;
+		u8 mac[ETH_ALEN];
+		unsigned int naddr = 1;
 
 		/*
 		 * We simplistically allocate our virtual interfaces
@@ -2891,6 +2895,26 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,
 				pidx);
 			goto err_free_dev;
 		}
+
+		err = t4vf_get_vf_mac_acl(adapter, pf, &naddr, mac);
+		if (err) {
+			dev_err(&pdev->dev,
+				"unable to determine MAC ACL address, "
+				"continuing anyway.. (status %d)\n", err);
+		} else if (naddr && adapter->params.vfres.nvi == 1) {
+			struct sockaddr addr;
+
+			ether_addr_copy(addr.sa_data, mac);
+			err = cxgb4vf_set_mac_addr(netdev, &addr);
+			if (err) {
+				dev_err(&pdev->dev,
+					"unable to set MAC address %pM\n",
+					mac);
+				goto err_free_dev;
+			}
+			dev_info(&pdev->dev,
+				 "Using assigned MAC ACL: %pM\n", mac);
+		}
 	}
 
 	/* See what interrupts we'll be using.  If we've been configured to
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h
index 438374a..b880401 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h
@@ -346,6 +346,7 @@ int t4vf_bar2_sge_qregs(struct adapter *adapter,
 			u64 *pbar2_qoffset,
 			unsigned int *pbar2_qid);
 
+unsigned int t4vf_get_pf_from_vf(struct adapter *);
 int t4vf_get_sge_params(struct adapter *);
 int t4vf_get_vpd_params(struct adapter *);
 int t4vf_get_dev_params(struct adapter *);
@@ -380,5 +381,7 @@ int t4vf_eth_eq_free(struct adapter *, unsigned int);
 
 int t4vf_handle_fw_rpl(struct adapter *, const __be64 *);
 int t4vf_prep_adapter(struct adapter *);
+int t4vf_get_vf_mac_acl(struct adapter *adapter, unsigned int pf,
+			unsigned int *naddr, u8 *addr);
 
 #endif /* __T4VF_COMMON_H__ */
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
index 955ff7c..9895bd2 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
@@ -583,6 +583,15 @@ int t4vf_bar2_sge_qregs(struct adapter *adapter,
 	return 0;
 }
 
+unsigned int t4vf_get_pf_from_vf(struct adapter *adapter)
+{
+        u32 whoami;
+
+        whoami = t4_read_reg(adapter, T4VF_PL_BASE_ADDR + PL_VF_WHOAMI_A);
+        return (CHELSIO_CHIP_VERSION(adapter->params.chip) <= CHELSIO_T5 ?
+			SOURCEPF_G(whoami) : T6_SOURCEPF_G(whoami));
+}
+
 /**
  *	t4vf_get_sge_params - retrieve adapter Scatter gather Engine parameters
  *	@adapter: the adapter
@@ -660,7 +669,6 @@ int t4vf_get_sge_params(struct adapter *adapter)
 	 * read.
 	 */
 	if (!is_t4(adapter->params.chip)) {
-		u32 whoami;
 		unsigned int pf, s_hps, s_qpp;
 
 		params[0] = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_REG) |
@@ -684,11 +692,7 @@ int t4vf_get_sge_params(struct adapter *adapter)
 		 * register we just read. Do it once here so other code in
 		 * the driver can just use it.
 		 */
-		whoami = t4_read_reg(adapter,
-				     T4VF_PL_BASE_ADDR + PL_VF_WHOAMI_A);
-		pf = CHELSIO_CHIP_VERSION(adapter->params.chip) <= CHELSIO_T5 ?
-			SOURCEPF_G(whoami) : T6_SOURCEPF_G(whoami);
-
+		pf = t4vf_get_pf_from_vf(adapter);
 		s_hps = (HOSTPAGESIZEPF0_S +
 			 (HOSTPAGESIZEPF1_S - HOSTPAGESIZEPF0_S) * pf);
 		sge_params->sge_vf_hps =
@@ -1749,3 +1753,50 @@ int t4vf_prep_adapter(struct adapter *adapter)
 
 	return 0;
 }
+
+/**
+ *	t4vf_get_vf_mac_acl - Get the MAC address to be set to
+ *			      the VI of this VF.
+ *	@adapter: The adapter
+ *	@pf: The pf associated with vf 
+ *	@naddr: the number of ACL MAC addresses returned in addr
+ *	@addr: Placeholder for MAC addresses
+ *
+ *	Find the MAC address to be set to the VF's VI. The requested MAC address
+ *	is from the host OS via callback in the PF driver.
+ */
+int t4vf_get_vf_mac_acl(struct adapter *adapter, unsigned int pf,
+			unsigned int *naddr, u8 *addr)
+{
+	struct fw_acl_mac_cmd cmd;
+	int ret;
+
+	memset(&cmd, 0, sizeof(cmd));
+	cmd.op_to_vfn = cpu_to_be32(FW_CMD_OP_V(FW_ACL_MAC_CMD) |
+				    FW_CMD_REQUEST_F |
+				    FW_CMD_READ_F);
+	cmd.en_to_len16 = cpu_to_be32((unsigned int)FW_LEN16(cmd));
+	ret = t4vf_wr_mbox(adapter, &cmd, sizeof(cmd), &cmd);
+	if (ret)
+		return ret;
+
+	if (cmd.nmac < *naddr)
+		*naddr = cmd.nmac;
+
+	switch (pf) {
+	case 3:
+		memcpy(addr, cmd.macaddr3, sizeof(cmd.macaddr3));
+		break;
+	case 2:
+		memcpy(addr, cmd.macaddr2, sizeof(cmd.macaddr2));
+		break;
+	case 1:
+		memcpy(addr, cmd.macaddr1, sizeof(cmd.macaddr1));
+		break;
+	case 0:
+		memcpy(addr, cmd.macaddr0, sizeof(cmd.macaddr0));
+		break;
+	}
+
+	return ret;
+}
-- 
1.7.3

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

* [PATCHv2 net-next iproute2 3/3] ip: Add option to specify PF number associated with the VF
  2016-06-30 15:34 [PATCHv2 net-next 0/3] Add option to specify PF parameter for IFLA_VF_MAC Hariprasad Shenai
  2016-06-30 15:34 ` [PATCHv2 net-next 1/3] net: Add provision to specify pf number while assigning VF mac Hariprasad Shenai
  2016-06-30 15:34 ` [PATCHv2 net-next 2/3] cxgb4/cxgb4vf: Add set VF mac address support Hariprasad Shenai
@ 2016-06-30 15:34 ` Hariprasad Shenai
  2 siblings, 0 replies; 7+ messages in thread
From: Hariprasad Shenai @ 2016-06-30 15:34 UTC (permalink / raw)
  To: davem, stephen; +Cc: netdev, nirranjan, leedom, kumaras, Hariprasad Shenai

Add options to specify PF number associated with the VF for MAC ACL.
The current API assumes that there is one to one mapping between
Network Ports, Physical Functions and the SR-IOV Virtual Function.
But that's not true in the case of Chelsio, our cards have SR-IOV
Capabilities on Physical Functions 0..3 and the PF Driver registers
ports on PF4.

Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com>
---
 include/linux/if_link.h |    1 +
 ip/ipaddress.c          |    3 +++
 ip/iplink.c             |   21 ++++++++++++++-------
 man/man8/ip-link.8.in   |   15 +++++++++++++--
 4 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index 15bbeb8..793c765 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -631,6 +631,7 @@ enum {
 #define IFLA_VF_MAX (__IFLA_VF_MAX - 1)
 
 struct ifla_vf_mac {
+	__u32 pf;
 	__u32 vf;
 	__u8 mac[32]; /* MAX_ADDR_LEN */
 };
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index df363b0..d67c89b 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -351,6 +351,9 @@ static void print_vfinfo(FILE *fp, struct rtattr *vfinfo)
 	fprintf(fp, "%s    vf %d MAC %s", _SL_, vf_mac->vf,
 		ll_addr_n2a((unsigned char *)&vf_mac->mac,
 			    ETH_ALEN, 0, b1, sizeof(b1)));
+	fprintf(fp, "%s    pf %d vf %d MAC %s", _SL_, vf_mac->pf,
+		vf_mac->pf, ll_addr_n2a((unsigned char *)&vf_mac->mac,
+		ETH_ALEN, 0, b1, sizeof(b1)));
 	if (vf_vlan->vlan)
 		fprintf(fp, ", vlan %d", vf_vlan->vlan);
 	if (vf_vlan->qos)
diff --git a/ip/iplink.c b/ip/iplink.c
index d2e586b..9c1b625 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -73,7 +73,7 @@ void iplink_usage(void)
 	fprintf(stderr, "	                  [ netns { PID | NAME } ]\n");
 	fprintf(stderr, "	                  [ link-netnsid ID ]\n");
 	fprintf(stderr, "			  [ alias NAME ]\n");
-	fprintf(stderr, "	                  [ vf NUM [ mac LLADDR ]\n");
+	fprintf(stderr, "	                  [ pf NUM vf NUM [ mac LLADDR ]\n");
 	fprintf(stderr, "				   [ vlan VLANID [ qos VLAN-QOS ] ]\n");
 
 	fprintf(stderr, "				   [ rate TXRATE ]\n");
@@ -237,7 +237,7 @@ struct iplink_req {
 	char			buf[1024];
 };
 
-static int iplink_parse_vf(int vf, int *argcp, char ***argvp,
+static int iplink_parse_vf(int pf, int vf, int *argcp, char ***argvp,
 			   struct iplink_req *req, int dev_index)
 {
 	char new_rate_api = 0, count = 0, override_legacy_rate = 0;
@@ -276,6 +276,7 @@ static int iplink_parse_vf(int vf, int *argcp, char ***argvp,
 			struct ifla_vf_mac ivm;
 
 			NEXT_ARG();
+			ivm.pf = pf;
 			ivm.vf = vf;
 			len = ll_addr_a2n((char *)ivm.mac, 32, *argv);
 			if (len < 0)
@@ -423,7 +424,7 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
 	int qlen = -1;
 	int mtu = -1;
 	int netns = -1;
-	int vf = -1;
+	int pf = -1, vf = -1;
 	int numtxqueues = -1;
 	int numrxqueues = -1;
 	int dev_index = 0;
@@ -540,19 +541,25 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
 				req->i.ifi_flags |= IFF_NOARP;
 			else
 				return on_off("arp", *argv);
-		} else if (strcmp(*argv, "vf") == 0) {
+		} else if (strcmp(*argv, "pf") == 0) {
 			struct rtattr *vflist;
 
 			NEXT_ARG();
-			if (get_integer(&vf,  *argv, 0))
-				invarg("Invalid \"vf\" value\n", *argv);
+			if (get_integer(&pf,  *argv, 0))
+				invarg("Invalid \"pf\" value\n", *argv);
+			NEXT_ARG();
+			if (strcmp(*argv, "vf") == 0) {
+				NEXT_ARG();
+				if (get_integer(&vf,  *argv, 0))
+					invarg("Invalid \"vf\" value\n", *argv);
+			}
 
 			vflist = addattr_nest(&req->n, sizeof(*req),
 					      IFLA_VFINFO_LIST);
 			if (dev_index == 0)
 				missarg("dev");
 
-			len = iplink_parse_vf(vf, &argc, &argv, req, dev_index);
+			len = iplink_parse_vf(pf, vf, &argc, &argv, req, dev_index);
 			if (len < 0)
 				return -1;
 			addattr_nest_end(&req->n, vflist);
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index 8fcce5e..a47b0e6 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -119,7 +119,9 @@ ip-link \- network device configuration
 .RB "[ " alias
 .IR NAME  " ]"
 .br
-.RB "[ " vf
+.RB "[ " pf
+.IR NUM
+.B  vf
 .IR NUM " ["
 .B  mac
 .IR LLADDR " ]"
@@ -1096,15 +1098,24 @@ The available groups are listed in file
 .BR "@SYSCONFDIR@/group" .
 
 .TP
+.BI pf " NUM"
+specify the Physical Function of the VF device that needs to be configured.
+The associated VF device must be specified using the
+.B vf
+parameter.
+
+.TP
 .BI vf " NUM"
 specify a Virtual Function device to be configured. The associated PF device
 must be specified using the
-.B dev
+.B pf
 parameter.
 
 .in +8
 .BI mac " LLADDRESS"
 - change the station address for the specified VF. The
+.B pf
+and
 .B vf
 parameter must be specified.
 
-- 
1.7.3

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

* Re: [PATCHv2 net-next 1/3] net: Add provision to specify pf number while assigning VF mac
  2016-06-30 15:34 ` [PATCHv2 net-next 1/3] net: Add provision to specify pf number while assigning VF mac Hariprasad Shenai
@ 2016-06-30 19:04   ` Yuval Mintz
  2016-07-01  3:10     ` Hariprasad Shenai
  0 siblings, 1 reply; 7+ messages in thread
From: Yuval Mintz @ 2016-06-30 19:04 UTC (permalink / raw)
  To: Hariprasad Shenai, David Miller, stephen
  Cc: netdev, nirranjan, leedom, kumaras

> Chelsio T4/T5 cards have SR-IOV Capabilities on Physical Functions
> 0..3 and the administrative Driver(cxgb4) attaches to Physical Function 4.
> Each of the Physical Functions 0..3 can support up to 16 Virtual
> Functions. With the current Linux APIs, a 2-Port card would only be
> able to use the Virtual Functions on Physical Functions 0..1 and not
> allow the Virtual Functions on Physical Functions 2..3 to be used since
> there are no Ports 2..3 on a 2-Port card.
>
> Also the current ip commands takes netdev as one of the argument, and
> it assumes a 1-to-1 mapping of Network Ports, Physical Functions and the
> SR-IOV Virtual Functions of those Physical Functions. But it is not
> true in our case and won't work for us.
> 
> Added a new argument to specify the PF number associated with the VF, to
> fix this.

I don't get it - what's the exact definition of 'Physical Function'?
Are we talking PCI functions? Logical partitons? Something else?

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

* Re: [PATCHv2 net-next 1/3] net: Add provision to specify pf number while assigning VF mac
  2016-06-30 19:04   ` Yuval Mintz
@ 2016-07-01  3:10     ` Hariprasad Shenai
       [not found]       ` <CO2PR11MB0088CA97ED5A2EC7D964536097250@CO2PR11MB0088.namprd11.prod.outlook.com>
  0 siblings, 1 reply; 7+ messages in thread
From: Hariprasad Shenai @ 2016-07-01  3:10 UTC (permalink / raw)
  To: Yuval Mintz; +Cc: David Miller, stephen, netdev, nirranjan, leedom, kumaras

On Thu, Jun 30, 2016 at 19:04:16 +0000, Yuval Mintz wrote:
> > Chelsio T4/T5 cards have SR-IOV Capabilities on Physical Functions
> > 0..3 and the administrative Driver(cxgb4) attaches to Physical Function 4.
> > Each of the Physical Functions 0..3 can support up to 16 Virtual
> > Functions. With the current Linux APIs, a 2-Port card would only be
> > able to use the Virtual Functions on Physical Functions 0..1 and not
> > allow the Virtual Functions on Physical Functions 2..3 to be used since
> > there are no Ports 2..3 on a 2-Port card.
> >
> > Also the current ip commands takes netdev as one of the argument, and
> > it assumes a 1-to-1 mapping of Network Ports, Physical Functions and the
> > SR-IOV Virtual Functions of those Physical Functions. But it is not
> > true in our case and won't work for us.
> > 
> > Added a new argument to specify the PF number associated with the VF, to
> > fix this.
> 
> I don't get it - what's the exact definition of 'Physical Function'?
> Are we talking PCI functions? Logical partitons? Something else?

Its PCIe physical function. Physical functions (PFs) are full-featured
PCIe functions; virtual functions (VFs) are “lightweight” functions that
lack configuration resource.

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

* Re: [PATCHv2 net-next 1/3] net: Add provision to specify pf number while assigning VF mac
       [not found]       ` <CO2PR11MB0088CA97ED5A2EC7D964536097250@CO2PR11MB0088.namprd11.prod.outlook.com>
@ 2016-07-19  7:40         ` Hariprasad Shenai
  0 siblings, 0 replies; 7+ messages in thread
From: Hariprasad Shenai @ 2016-07-19  7:40 UTC (permalink / raw)
  To: Yuval Mintz; +Cc: David Miller, stephen, netdev, nirranjan, leedom, kumaras

On Fri, Jul 01, 2016 at 04:41:52 +0000, Yuval Mintz wrote:
> > > > Chelsio T4/T5 cards have SR-IOV Capabilities on Physical Functions
> > > > 0..3 and the administrative Driver(cxgb4) attaches to Physical Function 4.
> > > > Each of the Physical Functions 0..3 can support up to 16 Virtual
> > > > Functions. With the current Linux APIs, a 2-Port card would only be
> > > > able to use the Virtual Functions on Physical Functions 0..1 and not
> > > > allow the Virtual Functions on Physical Functions 2..3 to be used since
> > > > there are no Ports 2..3 on a 2-Port card.
> > > >
> > > > Also the current ip commands takes netdev as one of the argument, and
> > > > it assumes a 1-to-1 mapping of Network Ports, Physical Functions and the
> > > > SR-IOV Virtual Functions of those Physical Functions. But it is not
> > > > true in our case and won't work for us.
> > > >
> > > > Added a new argument to specify the PF number associated with the VF, to
> > > > fix this.
> > >
> > > I don't get it - what's the exact definition of 'Physical Function'?
> > > Are we talking PCI functions? Logical partitons? Something else?
> 
> > Its PCIe physical function. Physical functions (PFs) are full-featured
> > PCIe functions; virtual functions (VFs) are "lightweight" functions that
> > lack configuration resource.
> 
> Seems like a bad precedent to me - the control node is always the netdevice.
> While I understand your need, looks like what you really want some kind of
> a dummy netdevice for the higher PFs through which you could control their
> VFs.

Hi Dave and all,

Based on above comment, since the control node should always be net_device, we
will go with the below implementation.

We will have dummy net devices with 00:00:00:00:00:00 mac address. The device
won't be associated with any port, since it doesn't need to transmit/receive.
On a two port adapter, we need to create 4 dummy net devices, corresponding to
PF0 ... PF3. Basically the dummy net device will have  callback's only 
for "ndo_set_vf_*" API's.

Thanks,
Hariprasad Shenai

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

end of thread, other threads:[~2016-07-19  7:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-30 15:34 [PATCHv2 net-next 0/3] Add option to specify PF parameter for IFLA_VF_MAC Hariprasad Shenai
2016-06-30 15:34 ` [PATCHv2 net-next 1/3] net: Add provision to specify pf number while assigning VF mac Hariprasad Shenai
2016-06-30 19:04   ` Yuval Mintz
2016-07-01  3:10     ` Hariprasad Shenai
     [not found]       ` <CO2PR11MB0088CA97ED5A2EC7D964536097250@CO2PR11MB0088.namprd11.prod.outlook.com>
2016-07-19  7:40         ` Hariprasad Shenai
2016-06-30 15:34 ` [PATCHv2 net-next 2/3] cxgb4/cxgb4vf: Add set VF mac address support Hariprasad Shenai
2016-06-30 15:34 ` [PATCHv2 net-next iproute2 3/3] ip: Add option to specify PF number associated with the VF Hariprasad Shenai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.