DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/ice: fix use of ice_bitmap_t in promisc functions
@ 2024-07-02 12:21 Ian Stokes
  2024-07-02 12:24 ` Stokes, Ian
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Stokes @ 2024-07-02 12:21 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Ian Stokes

Promisc functions were modified to use ice_bitmap_t.
However use of ice_bitmap_t requires specific helper
functions to ensure correctness.

Fix this by adding correct calls to declare, zero and set
ice_bitmap_t within the promisc functions.

Signed-off-by: Ian Stokes <ian.stokes@intel.com>
---
 drivers/net/ice/ice_ethdev.c | 59 +++++++++++++++++++++++-------------
 1 file changed, 38 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index f7189b2dfe..23f14d7c42 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -3807,7 +3807,8 @@ ice_dev_start(struct rte_eth_dev *dev)
 	uint8_t timer = hw->func_caps.ts_func_info.tmr_index_owned;
 	uint32_t pin_idx = ad->devargs.pin_idx;
 	struct rte_tm_error tm_err;
-	ice_bitmap_t pmask;
+	ice_declare_bitmap(pmask, ICE_PROMISC_MAX);
+	ice_zero_bitmap(pmask, ICE_PROMISC_MAX);
 
 	/* program Tx queues' context in hardware */
 	for (nb_txq = 0; nb_txq < data->nb_tx_queues; nb_txq++) {
@@ -3864,9 +3865,12 @@ ice_dev_start(struct rte_eth_dev *dev)
 		return -EIO;
 
 	/* Enable receiving broadcast packets and transmitting packets */
-	pmask = ICE_PROMISC_BCAST_RX | ICE_PROMISC_BCAST_TX |
-			ICE_PROMISC_UCAST_TX | ICE_PROMISC_MCAST_TX;
-	ret = ice_set_vsi_promisc(hw, vsi->idx, &pmask, 0);
+	ice_set_bit(ICE_PROMISC_BCAST_RX, pmask);
+	ice_set_bit(ICE_PROMISC_BCAST_TX, pmask);
+	ice_set_bit(ICE_PROMISC_UCAST_TX, pmask);
+	ice_set_bit(ICE_PROMISC_MCAST_TX, pmask);
+
+	ret = ice_set_vsi_promisc(hw, vsi->idx, pmask, 0);
 	if (ret != ICE_SUCCESS)
 		PMD_DRV_LOG(INFO, "fail to set vsi broadcast");
 
@@ -5211,12 +5215,15 @@ ice_promisc_enable(struct rte_eth_dev *dev)
 	struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct ice_vsi *vsi = pf->main_vsi;
 	int status, ret = 0;
-	ice_bitmap_t pmask;
+	ice_declare_bitmap(pmask, ICE_PROMISC_MAX);
+	ice_zero_bitmap(pmask, ICE_PROMISC_MAX);
 
-	pmask = ICE_PROMISC_UCAST_RX | ICE_PROMISC_UCAST_TX |
-		ICE_PROMISC_MCAST_RX | ICE_PROMISC_MCAST_TX;
+	ice_set_bit(ICE_PROMISC_UCAST_RX, pmask);
+	ice_set_bit(ICE_PROMISC_UCAST_TX, pmask);
+	ice_set_bit(ICE_PROMISC_MCAST_RX, pmask);
+	ice_set_bit(ICE_PROMISC_MCAST_TX, pmask);
 
-	status = ice_set_vsi_promisc(hw, vsi->idx, &pmask, 0);
+	status = ice_set_vsi_promisc(hw, vsi->idx, pmask, 0);
 	switch (status) {
 	case ICE_ERR_ALREADY_EXISTS:
 		PMD_DRV_LOG(DEBUG, "Promisc mode has already been enabled");
@@ -5237,15 +5244,21 @@ ice_promisc_disable(struct rte_eth_dev *dev)
 	struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct ice_vsi *vsi = pf->main_vsi;
 	int status, ret = 0;
-	ice_bitmap_t pmask;
+	ice_declare_bitmap(pmask, ICE_PROMISC_MAX);
+	ice_zero_bitmap(pmask, ICE_PROMISC_MAX);
 
-	if (dev->data->all_multicast == 1)
-		pmask = ICE_PROMISC_UCAST_RX | ICE_PROMISC_UCAST_TX;
-	else
-		pmask = ICE_PROMISC_UCAST_RX | ICE_PROMISC_UCAST_TX |
-			ICE_PROMISC_MCAST_RX | ICE_PROMISC_MCAST_TX;
+	if (dev->data->all_multicast == 1) {
+		ice_set_bit(ICE_PROMISC_UCAST_RX, pmask);
+		ice_set_bit(ICE_PROMISC_UCAST_TX, pmask);
+	}
+	else {
+		ice_set_bit(ICE_PROMISC_UCAST_RX, pmask);
+		ice_set_bit(ICE_PROMISC_UCAST_TX, pmask);
+		ice_set_bit(ICE_PROMISC_MCAST_RX, pmask);
+		ice_set_bit(ICE_PROMISC_MCAST_TX, pmask);
+	}
 
-	status = ice_clear_vsi_promisc(hw, vsi->idx, &pmask, 0);
+	status = ice_clear_vsi_promisc(hw, vsi->idx, pmask, 0);
 	if (status != ICE_SUCCESS) {
 		PMD_DRV_LOG(ERR, "Failed to clear promisc, err=%d", status);
 		ret = -EAGAIN;
@@ -5261,11 +5274,13 @@ ice_allmulti_enable(struct rte_eth_dev *dev)
 	struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct ice_vsi *vsi = pf->main_vsi;
 	int status, ret = 0;
-	ice_bitmap_t pmask;
+	ice_declare_bitmap(pmask, ICE_PROMISC_MAX);
+	ice_zero_bitmap(pmask, ICE_PROMISC_MAX);
 
-	pmask = ICE_PROMISC_MCAST_RX | ICE_PROMISC_MCAST_TX;
+	ice_set_bit(ICE_PROMISC_MCAST_RX, pmask);
+	ice_set_bit(ICE_PROMISC_MCAST_TX, pmask);
 
-	status = ice_set_vsi_promisc(hw, vsi->idx, &pmask, 0);
+	status = ice_set_vsi_promisc(hw, vsi->idx, pmask, 0);
 
 	switch (status) {
 	case ICE_ERR_ALREADY_EXISTS:
@@ -5287,14 +5302,16 @@ ice_allmulti_disable(struct rte_eth_dev *dev)
 	struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct ice_vsi *vsi = pf->main_vsi;
 	int status, ret = 0;
-	ice_bitmap_t pmask;
+	ice_declare_bitmap(pmask, ICE_PROMISC_MAX);
+	ice_zero_bitmap(pmask, ICE_PROMISC_MAX);
 
 	if (dev->data->promiscuous == 1)
 		return 0; /* must remain in all_multicast mode */
 
-	pmask = ICE_PROMISC_MCAST_RX | ICE_PROMISC_MCAST_TX;
+	ice_set_bit(ICE_PROMISC_MCAST_RX, pmask);
+	ice_set_bit(ICE_PROMISC_MCAST_TX, pmask);
 
-	status = ice_clear_vsi_promisc(hw, vsi->idx, &pmask, 0);
+	status = ice_clear_vsi_promisc(hw, vsi->idx, pmask, 0);
 	if (status != ICE_SUCCESS) {
 		PMD_DRV_LOG(ERR, "Failed to clear allmulti, err=%d", status);
 		ret = -EAGAIN;
-- 
2.34.1


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

* RE: [PATCH] net/ice: fix use of ice_bitmap_t in promisc functions
  2024-07-02 12:21 [PATCH] net/ice: fix use of ice_bitmap_t in promisc functions Ian Stokes
@ 2024-07-02 12:24 ` Stokes, Ian
  2024-07-02 12:27   ` Bruce Richardson
  0 siblings, 1 reply; 4+ messages in thread
From: Stokes, Ian @ 2024-07-02 12:24 UTC (permalink / raw)
  To: dev; +Cc: Richardson, Bruce

> Promisc functions were modified to use ice_bitmap_t.
> However use of ice_bitmap_t requires specific helper
> functions to ensure correctness.
> 
> Fix this by adding correct calls to declare, zero and set
> ice_bitmap_t within the promisc functions.
> 
> Signed-off-by: Ian Stokes <ian.stokes@intel.com>

Just to clarify, this patch is intended to be applied with the ice shared code update
which I believe is in net-next. It can either be added as an extra patch to that series
or merged with the original patch, whatever is preferred.

Thanks
Ian

> ---
>  drivers/net/ice/ice_ethdev.c | 59 +++++++++++++++++++++++-------------
>  1 file changed, 38 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
> index f7189b2dfe..23f14d7c42 100644
> --- a/drivers/net/ice/ice_ethdev.c
> +++ b/drivers/net/ice/ice_ethdev.c
> @@ -3807,7 +3807,8 @@ ice_dev_start(struct rte_eth_dev *dev)
>  	uint8_t timer = hw->func_caps.ts_func_info.tmr_index_owned;
>  	uint32_t pin_idx = ad->devargs.pin_idx;
>  	struct rte_tm_error tm_err;
> -	ice_bitmap_t pmask;
> +	ice_declare_bitmap(pmask, ICE_PROMISC_MAX);
> +	ice_zero_bitmap(pmask, ICE_PROMISC_MAX);
> 
>  	/* program Tx queues' context in hardware */
>  	for (nb_txq = 0; nb_txq < data->nb_tx_queues; nb_txq++) {
> @@ -3864,9 +3865,12 @@ ice_dev_start(struct rte_eth_dev *dev)
>  		return -EIO;
> 
>  	/* Enable receiving broadcast packets and transmitting packets */
> -	pmask = ICE_PROMISC_BCAST_RX | ICE_PROMISC_BCAST_TX |
> -			ICE_PROMISC_UCAST_TX |
> ICE_PROMISC_MCAST_TX;
> -	ret = ice_set_vsi_promisc(hw, vsi->idx, &pmask, 0);
> +	ice_set_bit(ICE_PROMISC_BCAST_RX, pmask);
> +	ice_set_bit(ICE_PROMISC_BCAST_TX, pmask);
> +	ice_set_bit(ICE_PROMISC_UCAST_TX, pmask);
> +	ice_set_bit(ICE_PROMISC_MCAST_TX, pmask);
> +
> +	ret = ice_set_vsi_promisc(hw, vsi->idx, pmask, 0);
>  	if (ret != ICE_SUCCESS)
>  		PMD_DRV_LOG(INFO, "fail to set vsi broadcast");
> 
> @@ -5211,12 +5215,15 @@ ice_promisc_enable(struct rte_eth_dev *dev)
>  	struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data-
> >dev_private);
>  	struct ice_vsi *vsi = pf->main_vsi;
>  	int status, ret = 0;
> -	ice_bitmap_t pmask;
> +	ice_declare_bitmap(pmask, ICE_PROMISC_MAX);
> +	ice_zero_bitmap(pmask, ICE_PROMISC_MAX);
> 
> -	pmask = ICE_PROMISC_UCAST_RX | ICE_PROMISC_UCAST_TX |
> -		ICE_PROMISC_MCAST_RX | ICE_PROMISC_MCAST_TX;
> +	ice_set_bit(ICE_PROMISC_UCAST_RX, pmask);
> +	ice_set_bit(ICE_PROMISC_UCAST_TX, pmask);
> +	ice_set_bit(ICE_PROMISC_MCAST_RX, pmask);
> +	ice_set_bit(ICE_PROMISC_MCAST_TX, pmask);
> 
> -	status = ice_set_vsi_promisc(hw, vsi->idx, &pmask, 0);
> +	status = ice_set_vsi_promisc(hw, vsi->idx, pmask, 0);
>  	switch (status) {
>  	case ICE_ERR_ALREADY_EXISTS:
>  		PMD_DRV_LOG(DEBUG, "Promisc mode has already been
> enabled");
> @@ -5237,15 +5244,21 @@ ice_promisc_disable(struct rte_eth_dev *dev)
>  	struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data-
> >dev_private);
>  	struct ice_vsi *vsi = pf->main_vsi;
>  	int status, ret = 0;
> -	ice_bitmap_t pmask;
> +	ice_declare_bitmap(pmask, ICE_PROMISC_MAX);
> +	ice_zero_bitmap(pmask, ICE_PROMISC_MAX);
> 
> -	if (dev->data->all_multicast == 1)
> -		pmask = ICE_PROMISC_UCAST_RX |
> ICE_PROMISC_UCAST_TX;
> -	else
> -		pmask = ICE_PROMISC_UCAST_RX |
> ICE_PROMISC_UCAST_TX |
> -			ICE_PROMISC_MCAST_RX |
> ICE_PROMISC_MCAST_TX;
> +	if (dev->data->all_multicast == 1) {
> +		ice_set_bit(ICE_PROMISC_UCAST_RX, pmask);
> +		ice_set_bit(ICE_PROMISC_UCAST_TX, pmask);
> +	}
> +	else {
> +		ice_set_bit(ICE_PROMISC_UCAST_RX, pmask);
> +		ice_set_bit(ICE_PROMISC_UCAST_TX, pmask);
> +		ice_set_bit(ICE_PROMISC_MCAST_RX, pmask);
> +		ice_set_bit(ICE_PROMISC_MCAST_TX, pmask);
> +	}
> 
> -	status = ice_clear_vsi_promisc(hw, vsi->idx, &pmask, 0);
> +	status = ice_clear_vsi_promisc(hw, vsi->idx, pmask, 0);
>  	if (status != ICE_SUCCESS) {
>  		PMD_DRV_LOG(ERR, "Failed to clear promisc, err=%d",
> status);
>  		ret = -EAGAIN;
> @@ -5261,11 +5274,13 @@ ice_allmulti_enable(struct rte_eth_dev *dev)
>  	struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data-
> >dev_private);
>  	struct ice_vsi *vsi = pf->main_vsi;
>  	int status, ret = 0;
> -	ice_bitmap_t pmask;
> +	ice_declare_bitmap(pmask, ICE_PROMISC_MAX);
> +	ice_zero_bitmap(pmask, ICE_PROMISC_MAX);
> 
> -	pmask = ICE_PROMISC_MCAST_RX | ICE_PROMISC_MCAST_TX;
> +	ice_set_bit(ICE_PROMISC_MCAST_RX, pmask);
> +	ice_set_bit(ICE_PROMISC_MCAST_TX, pmask);
> 
> -	status = ice_set_vsi_promisc(hw, vsi->idx, &pmask, 0);
> +	status = ice_set_vsi_promisc(hw, vsi->idx, pmask, 0);
> 
>  	switch (status) {
>  	case ICE_ERR_ALREADY_EXISTS:
> @@ -5287,14 +5302,16 @@ ice_allmulti_disable(struct rte_eth_dev *dev)
>  	struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data-
> >dev_private);
>  	struct ice_vsi *vsi = pf->main_vsi;
>  	int status, ret = 0;
> -	ice_bitmap_t pmask;
> +	ice_declare_bitmap(pmask, ICE_PROMISC_MAX);
> +	ice_zero_bitmap(pmask, ICE_PROMISC_MAX);
> 
>  	if (dev->data->promiscuous == 1)
>  		return 0; /* must remain in all_multicast mode */
> 
> -	pmask = ICE_PROMISC_MCAST_RX | ICE_PROMISC_MCAST_TX;
> +	ice_set_bit(ICE_PROMISC_MCAST_RX, pmask);
> +	ice_set_bit(ICE_PROMISC_MCAST_TX, pmask);
> 
> -	status = ice_clear_vsi_promisc(hw, vsi->idx, &pmask, 0);
> +	status = ice_clear_vsi_promisc(hw, vsi->idx, pmask, 0);
>  	if (status != ICE_SUCCESS) {
>  		PMD_DRV_LOG(ERR, "Failed to clear allmulti, err=%d", status);
>  		ret = -EAGAIN;
> --
> 2.34.1


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

* Re: [PATCH] net/ice: fix use of ice_bitmap_t in promisc functions
  2024-07-02 12:24 ` Stokes, Ian
@ 2024-07-02 12:27   ` Bruce Richardson
  2024-07-02 13:46     ` Bruce Richardson
  0 siblings, 1 reply; 4+ messages in thread
From: Bruce Richardson @ 2024-07-02 12:27 UTC (permalink / raw)
  To: Stokes, Ian; +Cc: dev

On Tue, Jul 02, 2024 at 01:24:03PM +0100, Stokes, Ian wrote:
> > Promisc functions were modified to use ice_bitmap_t.
> > However use of ice_bitmap_t requires specific helper
> > functions to ensure correctness.
> > 
> > Fix this by adding correct calls to declare, zero and set
> > ice_bitmap_t within the promisc functions.
> > 
> > Signed-off-by: Ian Stokes <ian.stokes@intel.com>
> 
> Just to clarify, this patch is intended to be applied with the ice shared code update
> which I believe is in net-next. It can either be added as an extra patch to that series
> or merged with the original patch, whatever is preferred.
> 
> Thanks
> Ian
> 

I think this change should be squashed to commit [1], since it is part of
the overall change from using bitmasks to actual bitmap type.

/Bruce

[1] http://git.dpdk.org/next/dpdk-next-net-intel/commit/?id=126916f331dfa9fd6e997c0d00b12222e29de9cc

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

* Re: [PATCH] net/ice: fix use of ice_bitmap_t in promisc functions
  2024-07-02 12:27   ` Bruce Richardson
@ 2024-07-02 13:46     ` Bruce Richardson
  0 siblings, 0 replies; 4+ messages in thread
From: Bruce Richardson @ 2024-07-02 13:46 UTC (permalink / raw)
  To: Stokes, Ian; +Cc: dev

On Tue, Jul 02, 2024 at 01:27:35PM +0100, Bruce Richardson wrote:
> On Tue, Jul 02, 2024 at 01:24:03PM +0100, Stokes, Ian wrote:
> > > Promisc functions were modified to use ice_bitmap_t.
> > > However use of ice_bitmap_t requires specific helper
> > > functions to ensure correctness.
> > > 
> > > Fix this by adding correct calls to declare, zero and set
> > > ice_bitmap_t within the promisc functions.
> > > 
> > > Signed-off-by: Ian Stokes <ian.stokes@intel.com>
> > 
> > Just to clarify, this patch is intended to be applied with the ice shared code update
> > which I believe is in net-next. It can either be added as an extra patch to that series
> > or merged with the original patch, whatever is preferred.
> > 
> > Thanks
> > Ian
> > 
> 
> I think this change should be squashed to commit [1], since it is part of
> the overall change from using bitmasks to actual bitmap type.
> 
> /Bruce
> 
> [1] http://git.dpdk.org/next/dpdk-next-net-intel/commit/?id=126916f331dfa9fd6e997c0d00b12222e29de9cc

Fix merged to appropriate commit on next-net-intel tree.

/Bruce

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

end of thread, other threads:[~2024-07-02 13:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-02 12:21 [PATCH] net/ice: fix use of ice_bitmap_t in promisc functions Ian Stokes
2024-07-02 12:24 ` Stokes, Ian
2024-07-02 12:27   ` Bruce Richardson
2024-07-02 13:46     ` Bruce Richardson

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