DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/ixgbe: add or remove MAC address
@ 2019-12-03 14:54 Guinan Sun
  2019-12-23  7:25 ` Ye Xiaolong
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Guinan Sun @ 2019-12-03 14:54 UTC (permalink / raw)
  To: dev; +Cc: Wenzhuo Lu, Qiming Yang, Beilei Xing, 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.

Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.h |  1 +
 drivers/net/ixgbe/ixgbe_pf.c     | 35 ++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 76a1b9d18..e1cd8fd16 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -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;
 };
 
 /*
diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
index d0d85e138..76dbed2ab 100644
--- a/drivers/net/ixgbe/ixgbe_pf.c
+++ b/drivers/net/ixgbe/ixgbe_pf.c
@@ -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;
-- 
2.17.1


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

* Re: [dpdk-dev] [PATCH] net/ixgbe: add or remove MAC address
  2019-12-03 14:54 [dpdk-dev] [PATCH] net/ixgbe: add or remove MAC address Guinan Sun
@ 2019-12-23  7:25 ` Ye Xiaolong
  2019-12-23  8:41   ` Sun, GuinanX
  2019-12-23  9:12 ` [dpdk-dev] [PATCH v2] net/ixgbe: add support for VF MAC address add and remove Guinan Sun
  2019-12-24  3:23 ` [dpdk-dev] [PATCH v3] " Guinan Sun
  2 siblings, 1 reply; 9+ messages in thread
From: Ye Xiaolong @ 2019-12-23  7:25 UTC (permalink / raw)
  To: Guinan Sun; +Cc: dev, Wenzhuo Lu, Qiming Yang, Beilei Xing

Hi, guinan

For the title, better to use

Add support for vf MAC address add and remove

or something like so.

On 12/03, Guinan Sun wrote:
>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?

>
>Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
>---
> drivers/net/ixgbe/ixgbe_ethdev.h |  1 +
> drivers/net/ixgbe/ixgbe_pf.c     | 35 ++++++++++++++++++++++++++++++++
> 2 files changed, 36 insertions(+)
>
>diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
>index 76a1b9d18..e1cd8fd16 100644
>--- a/drivers/net/ixgbe/ixgbe_ethdev.h
>+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
>@@ -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? 

> };
> 
> /*
>diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
>index d0d85e138..76dbed2ab 100644
>--- a/drivers/net/ixgbe/ixgbe_pf.c
>+++ b/drivers/net/ixgbe/ixgbe_pf.c
>@@ -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;

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

Thanks,
Xiaolong

>+
>+		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;
>-- 
>2.17.1
>

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

* Re: [dpdk-dev] [PATCH] net/ixgbe: add or remove MAC address
  2019-12-23  7:25 ` Ye Xiaolong
@ 2019-12-23  8:41   ` Sun, GuinanX
  0 siblings, 0 replies; 9+ messages in thread
From: Sun, GuinanX @ 2019-12-23  8:41 UTC (permalink / raw)
  To: Ye, Xiaolong; +Cc: dev, Lu, Wenzhuo, Yang, Qiming, Xing, Beilei

Hi Xiaolong

> -----Original Message-----
> From: Ye, Xiaolong
> Sent: Monday, December 23, 2019 3:25 PM
> To: Sun, GuinanX <guinanx.sun@intel.com>
> Cc: dev@dpdk.org; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Xing, Beilei <beilei.xing@intel.com>
> Subject: Re: [dpdk-dev] [PATCH] net/ixgbe: add or remove MAC address
> 
> 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

> 
> On 12/03, Guinan Sun wrote:
> >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

> 
> >
> >Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
> >---
> > drivers/net/ixgbe/ixgbe_ethdev.h |  1 +
> > drivers/net/ixgbe/ixgbe_pf.c     | 35 ++++++++++++++++++++++++++++++++
> > 2 files changed, 36 insertions(+)
> >
> >diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h
> >b/drivers/net/ixgbe/ixgbe_ethdev.h
> >index 76a1b9d18..e1cd8fd16 100644
> >--- a/drivers/net/ixgbe/ixgbe_ethdev.h
> >+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
> >@@ -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.

> 
> > };
> >
> > /*
> >diff --git a/drivers/net/ixgbe/ixgbe_pf.c
> >b/drivers/net/ixgbe/ixgbe_pf.c index d0d85e138..76dbed2ab 100644
> >--- a/drivers/net/ixgbe/ixgbe_pf.c
> >+++ b/drivers/net/ixgbe/ixgbe_pf.c
> >@@ -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;
> 
> 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.

> 
> Thanks,
> Xiaolong
> 
> >+
> >+		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;
> >--
> >2.17.1
> >

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

* [dpdk-dev] [PATCH v2] net/ixgbe: add support for VF MAC address add and remove
  2019-12-03 14:54 [dpdk-dev] [PATCH] net/ixgbe: add or remove MAC address Guinan Sun
  2019-12-23  7:25 ` Ye Xiaolong
@ 2019-12-23  9:12 ` Guinan Sun
  2019-12-24  2:34   ` Ye Xiaolong
  2019-12-24  3:23 ` [dpdk-dev] [PATCH v3] " Guinan Sun
  2 siblings, 1 reply; 9+ messages in thread
From: Guinan Sun @ 2019-12-23  9:12 UTC (permalink / raw)
  To: dev; +Cc: Beilei Xing, Qi Zhang, Qiming Yang, 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.

Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
---
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(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 76a1b9d18..e1cd8fd16 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -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;
 };
 
 /*
diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
index d0d85e138..78fc8c5f1 100644
--- a/drivers/net/ixgbe/ixgbe_pf.c
+++ b/drivers/net/ixgbe/ixgbe_pf.c
@@ -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;
-- 
2.17.1


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

* Re: [dpdk-dev] [PATCH v2] net/ixgbe: add support for VF MAC address add and remove
  2019-12-23  9:12 ` [dpdk-dev] [PATCH v2] net/ixgbe: add support for VF MAC address add and remove Guinan Sun
@ 2019-12-24  2:34   ` Ye Xiaolong
  0 siblings, 0 replies; 9+ messages in thread
From: Ye Xiaolong @ 2019-12-24  2:34 UTC (permalink / raw)
  To: Guinan Sun; +Cc: dev, Beilei Xing, Qi Zhang, Qiming Yang

On 12/23, Guinan Sun wrote:
>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>
>---
>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(+)
>
>diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
>index 76a1b9d18..e1cd8fd16 100644
>--- a/drivers/net/ixgbe/ixgbe_ethdev.h
>+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
>@@ -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;
> };
> 
> /*
>diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
>index d0d85e138..78fc8c5f1 100644
>--- a/drivers/net/ixgbe/ixgbe_pf.c
>+++ b/drivers/net/ixgbe/ixgbe_pf.c
>@@ -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);

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

Thanks,
Xiaolong
>+			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;
>-- 
>2.17.1
>

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

* [dpdk-dev] [PATCH v3] net/ixgbe: add support for VF MAC address add and remove
  2019-12-03 14:54 [dpdk-dev] [PATCH] net/ixgbe: add or remove MAC address Guinan Sun
  2019-12-23  7:25 ` Ye Xiaolong
  2019-12-23  9:12 ` [dpdk-dev] [PATCH v2] net/ixgbe: add support for VF MAC address add and remove Guinan Sun
@ 2019-12-24  3:23 ` Guinan Sun
  2019-12-24  6:06   ` Ye Xiaolong
  2020-05-08  6:58   ` Zhao1, Wei
  2 siblings, 2 replies; 9+ messages in thread
From: Guinan Sun @ 2019-12-24  3:23 UTC (permalink / raw)
  To: dev; +Cc: Wenzhuo Lu, Qiming Yang, 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.

Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
---
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(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 76a1b9d18..e1cd8fd16 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -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;
 };
 
 /*
diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
index d0d85e138..c93c0fdc2 100644
--- a/drivers/net/ixgbe/ixgbe_pf.c
+++ b/drivers/net/ixgbe/ixgbe_pf.c
@@ -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;
-- 
2.17.1


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

* Re: [dpdk-dev] [PATCH v3] net/ixgbe: add support for VF MAC address add and remove
  2019-12-24  3:23 ` [dpdk-dev] [PATCH v3] " Guinan Sun
@ 2019-12-24  6:06   ` Ye Xiaolong
  2020-05-08  6:58   ` Zhao1, Wei
  1 sibling, 0 replies; 9+ messages in thread
From: Ye Xiaolong @ 2019-12-24  6:06 UTC (permalink / raw)
  To: Guinan Sun; +Cc: dev, Wenzhuo Lu, Qiming Yang

On 12/24, Guinan Sun wrote:
>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>
>---
>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(+)
>
>diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
>index 76a1b9d18..e1cd8fd16 100644
>--- a/drivers/net/ixgbe/ixgbe_ethdev.h
>+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
>@@ -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;
> };
> 
> /*
>diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
>index d0d85e138..c93c0fdc2 100644
>--- a/drivers/net/ixgbe/ixgbe_pf.c
>+++ b/drivers/net/ixgbe/ixgbe_pf.c
>@@ -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;
>-- 
>2.17.1
>

Acked-by: Xiaolong Ye <xiaolong.ye@intel.com>

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

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

* Re: [dpdk-dev] [PATCH v3] net/ixgbe: add support for VF MAC address add and remove
  2019-12-24  3:23 ` [dpdk-dev] [PATCH v3] " Guinan Sun
  2019-12-24  6:06   ` Ye Xiaolong
@ 2020-05-08  6:58   ` Zhao1, Wei
  2020-05-08  8:19     ` Sun, GuinanX
  1 sibling, 1 reply; 9+ messages in thread
From: Zhao1, Wei @ 2020-05-08  6:58 UTC (permalink / raw)
  To: Sun, GuinanX, dev; +Cc: Lu, Wenzhuo, Yang, Qiming, Sun, GuinanX, Guo, Jia

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.


> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Guinan Sun
> Sent: Tuesday, December 24, 2019 11:24 AM
> To: dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Sun, GuinanX <guinanx.sun@intel.com>
> 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.
> 
> Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
> ---
> 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(+)
> 
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h
> b/drivers/net/ixgbe/ixgbe_ethdev.h
> index 76a1b9d18..e1cd8fd16 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.h
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.h
> @@ -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;
>  };
> 
>  /*
> diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c index
> d0d85e138..c93c0fdc2 100644
> --- a/drivers/net/ixgbe/ixgbe_pf.c
> +++ b/drivers/net/ixgbe/ixgbe_pf.c
> @@ -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;
> --
> 2.17.1


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

* Re: [dpdk-dev] [PATCH v3] net/ixgbe: add support for VF MAC address add and remove
  2020-05-08  6:58   ` Zhao1, Wei
@ 2020-05-08  8:19     ` Sun, GuinanX
  0 siblings, 0 replies; 9+ messages in thread
From: Sun, GuinanX @ 2020-05-08  8:19 UTC (permalink / raw)
  To: Zhao1, Wei, dev; +Cc: Lu, Wenzhuo, Yang, Qiming, Guo, Jia

Hi zhaowei

> -----Original Message-----
> From: Zhao1, Wei
> Sent: Friday, May 8, 2020 2:58 PM
> To: Sun, GuinanX <guinanx.sun@intel.com>; dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Sun, GuinanX <guinanx.sun@intel.com>; Guo, Jia
> <jia.guo@intel.com>
> Subject: RE: [dpdk-dev] [PATCH v3] net/ixgbe: add support for VF MAC address
> add and remove
> 
> 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.

> 
> > -----Original Message-----
> > From: dev <dev-bounces@dpdk.org> On Behalf Of Guinan Sun
> > Sent: Tuesday, December 24, 2019 11:24 AM
> > To: dev@dpdk.org
> > Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> > <qiming.yang@intel.com>; Sun, GuinanX <guinanx.sun@intel.com>
> > 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.
> >
> > Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
> > ---
> > 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(+)
> >
> > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h
> > b/drivers/net/ixgbe/ixgbe_ethdev.h
> > index 76a1b9d18..e1cd8fd16 100644
> > --- a/drivers/net/ixgbe/ixgbe_ethdev.h
> > +++ b/drivers/net/ixgbe/ixgbe_ethdev.h
> > @@ -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;
> >  };
> >
> >  /*
> > diff --git a/drivers/net/ixgbe/ixgbe_pf.c
> > b/drivers/net/ixgbe/ixgbe_pf.c index
> > d0d85e138..c93c0fdc2 100644
> > --- a/drivers/net/ixgbe/ixgbe_pf.c
> > +++ b/drivers/net/ixgbe/ixgbe_pf.c
> > @@ -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;
> > --
> > 2.17.1
> 


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

end of thread, other threads:[~2020-05-08  8:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-03 14:54 [dpdk-dev] [PATCH] net/ixgbe: add or remove MAC address Guinan Sun
2019-12-23  7:25 ` Ye Xiaolong
2019-12-23  8:41   ` Sun, GuinanX
2019-12-23  9:12 ` [dpdk-dev] [PATCH v2] net/ixgbe: add support for VF MAC address add and remove Guinan Sun
2019-12-24  2:34   ` Ye Xiaolong
2019-12-24  3:23 ` [dpdk-dev] [PATCH v3] " Guinan Sun
2019-12-24  6:06   ` Ye Xiaolong
2020-05-08  6:58   ` Zhao1, Wei
2020-05-08  8:19     ` Sun, GuinanX

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).