net/ixgbe: support VF MAC address add/remove
authorGuinan Sun <guinanx.sun@intel.com>
Tue, 24 Dec 2019 03:23:57 +0000 (03:23 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 17 Jan 2020 18:46:01 +0000 (19:46 +0100)
Ixgbe PMD PF host code needs to support ixgbevf MAC address
add and remove. For this purpose, a response was added
between PF and VF to update the MAC address.

Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Acked-by: Xiaolong Ye <xiaolong.ye@intel.com>
drivers/net/ixgbe/ixgbe_ethdev.h
drivers/net/ixgbe/ixgbe_pf.c

index 76a1b9d..e1cd8fd 100644 (file)
@@ -270,6 +270,7 @@ struct ixgbe_vf_info {
        uint8_t api_version;
        uint16_t switch_domain_id;
        uint16_t xcast_mode;
+       uint16_t mac_count;
 };
 
 /*
index 66b856e..493f0f2 100644 (file)
@@ -761,6 +761,37 @@ out:
        return 0;
 }
 
+static int
+ixgbe_set_vf_macvlan_msg(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
+{
+       struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+       struct ixgbe_vf_info *vf_info =
+               *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
+       uint8_t *new_mac = (uint8_t *)(&msgbuf[1]);
+       int index = (msgbuf[0] & IXGBE_VT_MSGINFO_MASK) >>
+                   IXGBE_VT_MSGINFO_SHIFT;
+
+       if (index) {
+               if (new_mac == NULL)
+                       return -1;
+
+               if (!rte_is_valid_assigned_ether_addr(
+                       (struct rte_ether_addr *)new_mac)) {
+                       PMD_DRV_LOG(ERR, "set invalid mac vf:%d\n", vf);
+                       return -1;
+               }
+
+               vf_info[vf].mac_count++;
+
+               hw->mac.ops.set_rar(hw, vf_info[vf].mac_count,
+                               new_mac, vf, IXGBE_RAH_AV);
+       } else {
+               hw->mac.ops.clear_rar(hw, vf_info[vf].mac_count);
+               vf_info[vf].mac_count = 0;
+       }
+       return 0;
+}
+
 static int
 ixgbe_rcv_msg_from_vf(struct rte_eth_dev *dev, uint16_t vf)
 {
@@ -848,6 +879,10 @@ ixgbe_rcv_msg_from_vf(struct rte_eth_dev *dev, uint16_t vf)
                if (retval == RTE_PMD_IXGBE_MB_EVENT_PROCEED)
                        retval = ixgbe_set_vf_mc_promisc(dev, vf, msgbuf);
                break;
+       case IXGBE_VF_SET_MACVLAN:
+               if (retval == RTE_PMD_IXGBE_MB_EVENT_PROCEED)
+                       retval = ixgbe_set_vf_macvlan_msg(dev, vf, msgbuf);
+               break;
        default:
                PMD_DRV_LOG(DEBUG, "Unhandled Msg %8.8x", (unsigned)msgbuf[0]);
                retval = IXGBE_ERR_MBX;