Skip to contentSkip to conversation

net/ixgbe: add or remove MAC address

PATCH In review Guinan Sun 3 participants 9 messages Dec 3, 2019 – May 8, 2020 Network drivers

lore
Share & tools
lore

Guinan Sun

author
#0 lore raw

PATCH 1/1 net/ixgbe: add or remove MAC address

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.

---
 drivers/net/ixgbe/ixgbe_ethdev.h |  1 +
 drivers/net/ixgbe/ixgbe_pf.c     | 35 ++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
index 76a1b9d18..e1cd8fd16 100644
@@ -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;
 };
 
 /*
drivers/net/ixgbe/ixgbe_pf.c +35 -0
index d0d85e138..76dbed2ab 100644
@@ -748,6 +748,37 @@ ixgbe_set_vf_mc_promisc(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
 	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 (!rte_is_valid_assigned_ether_addr(
+			(struct rte_ether_addr *)new_mac)) {
+			RTE_LOG(ERR, PMD, "set invalid mac vf:%d\n", vf);
+			return -1;
+		}
+
+		if (new_mac == NULL)
+			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)
 {
@@ -835,6 +866,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;
Signature · 1 line
2.17.1
#1 lore raw

Hi, guinan

For the title, better to use

Add support for vf MAC address add and remove

or something like so.

Quoted 3 lines · Guinan Sun

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.

Does this mean each one vf can have multiple MAC addresses after this patch, or this add actually means to replace the old mac address with the new one?

Quoted 12 lines

---
drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
drivers/net/ixgbe/ixgbe_pf.c | 35 ++++++++++++++++++++++++++++++++

2 files changed, 36 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.h +0 -0
index 76a1b9d18..e1cd8fd16 100644

drivers/net/ixgbe/ixgbe_ethdev.h struct ixgbe_vf_info { · line 273

Quoted 4 lines
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
@@ -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;

How is this mac_count initialized?

Quoted 20 lines
drivers/net/ixgbe/ixgbe_ethdev.h +0 -0
 };
 
 /*
drivers/net/ixgbe/ixgbe_pf.c +9 -0
index d0d85e138..76dbed2ab 100644
@@ -748,6 +748,37 @@ ixgbe_set_vf_mc_promisc(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
 	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;

drivers/net/ixgbe/ixgbe_pf.c ixgbe_set_vf_mc_promisc(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf) · line 769

Quoted 10 lines
drivers/net/ixgbe/ixgbe_pf.c +10 -0
+
+	if (index) {
+		if (!rte_is_valid_assigned_ether_addr(
+			(struct rte_ether_addr *)new_mac)) {
+			RTE_LOG(ERR, PMD, "set invalid mac vf:%d\n", vf);
+			return -1;
+		}
+
+		if (new_mac == NULL)
+			return -1;

I feel the null check should be in front of valid ether addr check, otherwise there might be null pointer reference issue.

Thanks,
Xiaolong

Quoted 29 lines
drivers/net/ixgbe/ixgbe_pf.c +12 -0
+
+		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) {

drivers/net/ixgbe/ixgbe_pf.c +4 -0
@@ -835,6 +866,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;
Signature · 1 line
2.17.1
#2 lore raw

Hi Xiaolong

Quoted 8 lines

-----Original Message-----
From: Ye, Xiaolong
Sent: Monday, December 23, 2019 3:25 PM
To: Sun, GuinanX <[email protected]>
Cc: [email protected]; Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] net/ixgbe: add or remove MAC address

Quoted 7 lines

Hi, guinan

For the title, better to use

Add support for vf MAC address add and remove

or something like so.

I agree with you and I will fix it in V2's patch

Quoted 8 lines · Guinan Sun
Quoted 3 lines

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.

Does this mean each one vf can have multiple MAC addresses after this patch, or this add actually means to replace the old mac address with the new one?

It means each one vf can have multiple MAC addresses after this patch

Quoted 8 lines
Quoted 8 lines

---
drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
drivers/net/ixgbe/ixgbe_pf.c | 35 ++++++++++++++++++++++++++++++++

2 files changed, 36 insertions(+)
Quoted 12 lines

drivers/net/ixgbe/ixgbe_ethdev.h struct ixgbe_vf_info { · line 273

Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
index 76a1b9d18..e1cd8fd16 100644
@@ -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;

How is this mac_count initialized?

This variable is initialized to 0 when the ixgbe_adapter structure is initialized, and the method is similar to vlan_count.

Quoted 29 lines

drivers/net/ixgbe/ixgbe_pf.c ixgbe_set_vf_mc_promisc(struct rte_eth_dev *dev,

Quoted 9 lines
drivers/net/ixgbe/ixgbe_ethdev.h +0 -0
 };
 
 /*
(quoted diff) +0 -0

b/drivers/net/ixgbe/ixgbe_pf.c index d0d85e138..76dbed2ab 100644

drivers/net/ixgbe/ixgbe_pf.c +0 -0
@@ -748,6 +748,37 @@ ixgbe_set_vf_mc_promisc(struct rte_eth_dev *dev,

uint32_t vf, uint32_t *msgbuf)

Quoted 19 lines
drivers/net/ixgbe/ixgbe_pf.c +14 -0
 	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 (!rte_is_valid_assigned_ether_addr(
+			(struct rte_ether_addr *)new_mac)) {
+			RTE_LOG(ERR, PMD, "set invalid mac vf:%d\n", vf);
Quoted 8 lines

drivers/net/ixgbe/ixgbe_pf.c ixgbe_set_vf_mc_promisc(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf) · line 769

Quoted 5 lines
drivers/net/ixgbe/ixgbe_pf.c +5 -0
+			return -1;
+		}
+
+		if (new_mac == NULL)
+			return -1;

I feel the null check should be in front of valid ether addr check, otherwise there might be null pointer reference issue.

Ok,I will fix it in V2's patch.

Quoted 34 lines

Thanks,
Xiaolong

Quoted 12 lines
drivers/net/ixgbe/ixgbe_pf.c +12 -0
+
+		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;
+}
+
Quoted 3 lines

static int
ixgbe_rcv_msg_from_vf(struct rte_eth_dev *dev, uint16_t vf) { @@ -835,6 +866,10 @@ ixgbe_rcv_msg_from_vf(struct rte_eth_dev *dev, uint16_t

vf)

Quoted 9 lines
		if (retval == RTE_PMD_IXGBE_MB_EVENT_PROCEED)
			retval = ixgbe_set_vf_mc_promisc(dev, vf, msgbuf);
		break;
drivers/net/ixgbe/ixgbe_pf.c +4 -0
+	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]);

Quoted 4 lines
		retval = IXGBE_ERR_MBX;

--
2.17.1

author
#3 lore raw

PATCH v2 1/1 net/ixgbe: add support for VF MAC address add and remove

In reply to Guinan Sun

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.

---
v2:
* Changed the title of commit message.
* Checked null in front of valid ether addr check.

---
 drivers/net/ixgbe/ixgbe_ethdev.h |  1 +
 drivers/net/ixgbe/ixgbe_pf.c     | 35 ++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
index 76a1b9d18..e1cd8fd16 100644
@@ -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;
 };
 
 /*
drivers/net/ixgbe/ixgbe_pf.c +35 -0
index d0d85e138..78fc8c5f1 100644
@@ -748,6 +748,37 @@ ixgbe_set_vf_mc_promisc(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
 	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)) {
+			RTE_LOG(ERR, PMD, "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)
 {
@@ -835,6 +866,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;
Signature · 1 line
2.17.1
#4 lore raw

Re: [dpdk-dev] [PATCH v2] net/ixgbe: add support for VF MAC address add and remove

Quoted 41 lines · Guinan Sun

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.

---
v2:
* Changed the title of commit message.
* Checked null in front of valid ether addr check.
---
drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
drivers/net/ixgbe/ixgbe_pf.c | 35 ++++++++++++++++++++++++++++++++

2 files changed, 36 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
index 76a1b9d18..e1cd8fd16 100644
@@ -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;
 };
 
 /*
drivers/net/ixgbe/ixgbe_pf.c +7 -0
index d0d85e138..78fc8c5f1 100644
@@ -748,6 +748,37 @@ ixgbe_set_vf_mc_promisc(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
 	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]);

drivers/net/ixgbe/ixgbe_pf.c ixgbe_set_vf_mc_promisc(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf) · line 767

Quoted 10 lines
drivers/net/ixgbe/ixgbe_pf.c +10 -0
+	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)) {
+			RTE_LOG(ERR, PMD, "set invalid mac vf:%d\n", vf);

Better to use PMD_DRV_LOG so as to be aligned with other logging.

Thanks,
Xiaolong

Quoted 31 lines
drivers/net/ixgbe/ixgbe_pf.c +14 -0
+			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) {

drivers/net/ixgbe/ixgbe_pf.c +4 -0
@@ -835,6 +866,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;
Signature · 1 line
2.17.1
author
#5 lore raw

PATCH v3 1/1 net/ixgbe: add support for VF MAC address add and remove

In reply to Guinan Sun

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.

---
v3:
* Changed from RTE_LOG to PMD_DRV_LOG. v2:
* Changed the title of commit message.
* Checked null in front of valid ether addr check.

---
 drivers/net/ixgbe/ixgbe_ethdev.h |  1 +
 drivers/net/ixgbe/ixgbe_pf.c     | 35 ++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
index 76a1b9d18..e1cd8fd16 100644
@@ -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;
 };
 
 /*
drivers/net/ixgbe/ixgbe_pf.c +35 -0
index d0d85e138..c93c0fdc2 100644
@@ -748,6 +748,37 @@ ixgbe_set_vf_mc_promisc(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
 	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)
 {
@@ -835,6 +866,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;
Signature · 1 line
2.17.1
Acked-by on v3 1/1 Applied
#6 lore raw

Re: [dpdk-dev] [PATCH v3] net/ixgbe: add support for VF MAC address add and remove

Quoted 84 lines · Guinan Sun

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.

---
v3:
* Changed from RTE_LOG to PMD_DRV_LOG. v2:
* Changed the title of commit message.
* Checked null in front of valid ether addr check.
---
drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
drivers/net/ixgbe/ixgbe_pf.c | 35 ++++++++++++++++++++++++++++++++

2 files changed, 36 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
index 76a1b9d18..e1cd8fd16 100644
@@ -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;
 };
 
 /*
drivers/net/ixgbe/ixgbe_pf.c +31 -0
index d0d85e138..c93c0fdc2 100644
@@ -748,6 +748,37 @@ ixgbe_set_vf_mc_promisc(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
 	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) {

drivers/net/ixgbe/ixgbe_pf.c +4 -0
@@ -835,6 +866,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;
Signature · 1 line
2.17.1

Applied to dpdk-next-net-intel, Thanks.

#7 lore raw

Re: [dpdk-dev] [PATCH v3] net/ixgbe: add support for VF MAC address add and remove

In reply to Guinan Sun

Hi, Guinan

There is a bug for this patch:
The second input parameter of function hw->mac.ops.set_rar() should be index of MAC address register IXGBE_RAL/H. This index should be management by pf host for all the vf, not only index for one vf, or vf1 maybe overwrite this MAC address of vf0. Although this patch has been merged, please commit fix patch for it.

Quoted 96 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Guinan Sun
Sent: Tuesday, December 24, 2019 11:24 AM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>; Sun, GuinanX <[email protected]>
Subject: [dpdk-dev] [PATCH v3] net/ixgbe: add support for VF MAC address add and remove

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.

---
v3:
* Changed from RTE_LOG to PMD_DRV_LOG. v2:
* Changed the title of commit message.
* Checked null in front of valid ether addr check.

---
 drivers/net/ixgbe/ixgbe_ethdev.h |  1 +
 drivers/net/ixgbe/ixgbe_pf.c     | 35
++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
index 76a1b9d18..e1cd8fd16 100644
@@ -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;
 };
 
 /*
drivers/net/ixgbe/ixgbe_pf.c index renamed from drivers/net/ixgbe/ixgbe_pf.c +0 -0

d0d85e138..c93c0fdc2 100644

drivers/net/ixgbe/ixgbe_pf.c +31 -0
@@ -748,6 +748,37 @@ ixgbe_set_vf_mc_promisc(struct rte_eth_dev *dev,
 uint32_t vf, uint32_t *msgbuf)
 	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) { @@ -835,6
+866,10 @@ ixgbe_rcv_msg_from_vf(struct rte_eth_dev *dev, uint16_t vf)

drivers/net/ixgbe/ixgbe_pf.c +4 -0
 		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;
--
2.17.1

#8 lore raw

Re: [dpdk-dev] [PATCH v3] net/ixgbe: add support for VF MAC address add and remove

Hi zhaowei

Quoted 10 lines

-----Original Message-----
From: Zhao1, Wei
Sent: Friday, May 8, 2020 2:58 PM
To: Sun, GuinanX <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>; Sun, GuinanX <[email protected]>; Guo, Jia <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v3] net/ixgbe: add support for VF MAC address add and remove

Quoted 9 lines

Hi, Guinan

There is a bug for this patch:
The second input parameter of function hw->mac.ops.set_rar() should be index of MAC address register IXGBE_RAL/H.
This index should be management by pf host for all the vf, not only index for one vf, or vf1 maybe overwrite this MAC address of vf0.
Although this patch has been merged, please commit fix patch for it.

I will double check for this function.
Thank you very much.

Quoted 92 lines
Quoted 91 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Guinan Sun
Sent: Tuesday, December 24, 2019 11:24 AM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>; Sun, GuinanX <[email protected]>
Subject: [dpdk-dev] [PATCH v3] net/ixgbe: add support for VF MAC address add and remove

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.

---
v3:
* Changed from RTE_LOG to PMD_DRV_LOG. v2:
* Changed the title of commit message.
* Checked null in front of valid ether addr check.

---
 drivers/net/ixgbe/ixgbe_ethdev.h |  1 +
 drivers/net/ixgbe/ixgbe_pf.c     | 35
++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
index 76a1b9d18..e1cd8fd16 100644
@@ -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;
 };
 
 /*
(quoted diff) +0 -0

b/drivers/net/ixgbe/ixgbe_pf.c index
d0d85e138..c93c0fdc2 100644

drivers/net/ixgbe/ixgbe_pf.c +31 -1
@@ -748,6 +748,37 @@ ixgbe_set_vf_mc_promisc(struct rte_eth_dev *dev,
 uint32_t vf, uint32_t *msgbuf)  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)  { @@
-835,6
+866,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;

drivers/net/ixgbe/ixgbe_pf.c +3 -0
+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;
--
2.17.1