linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net PATCH] octeontx2-pf: Fix ntuple rule creation to direct packet to VF with higher Rx queue than its PF
@ 2023-11-20  5:51 Suman Ghosh
  2023-11-20 12:02 ` Wojciech Drewek
  0 siblings, 1 reply; 5+ messages in thread
From: Suman Ghosh @ 2023-11-20  5:51 UTC (permalink / raw)
  To: sgoutham, gakula, sbhatta, hkelam, lcherian, jerinj, davem,
	edumazet, kuba, pabeni, netdev, linux-kernel, horms
  Cc: Suman Ghosh

It is possible to add a ntuple rule which would like to direct packet to
a VF whose number of queues are greater/less than its PF's queue numbers.
For example a PF can have 2 Rx queues but a VF created on that PF can have
8 Rx queues. As of today, ntuple rule will reject rule because it is
checking the requested queue number against PF's number of Rx queues.
As a part of this fix if the action of a ntuple rule is to move a packet
to a VF's queue then the check is removed. Also, a debug information is
printed to aware user that it is user's responsibility to cross check if
the requested queue number on that VF is a valid one.

Fixes: f0a1913f8a6f ("octeontx2-pf: Add support for ethtool ntuple filters")
Signed-off-by: Suman Ghosh <sumang@marvell.com>
---
 .../marvell/octeontx2/nic/otx2_flows.c        | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
index 4762dbea64a1..4200f2d387f6 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
@@ -1088,6 +1088,7 @@ int otx2_add_flow(struct otx2_nic *pfvf, struct ethtool_rxnfc *nfc)
 	struct ethhdr *eth_hdr;
 	bool new = false;
 	int err = 0;
+	u64 vf_num;
 	u32 ring;
 
 	if (!flow_cfg->max_flows) {
@@ -1100,9 +1101,26 @@ int otx2_add_flow(struct otx2_nic *pfvf, struct ethtool_rxnfc *nfc)
 	if (!(pfvf->flags & OTX2_FLAG_NTUPLE_SUPPORT))
 		return -ENOMEM;
 
+	/* Number of queues on a VF can be greater or less than
+	 * the PF's queue. Hence no need to check for the
+	 * queue count. Hence no need to check queue count if PF
+	 * is installing for its VF. Below is the expected vf_num value
+	 * based on the ethtool commands.
+	 *
+	 * e.g.
+	 * 1. ethtool -U <netdev> ... action -1  ==> vf_num:255
+	 * 2. ethtool -U <netdev> ... action <queue_num>  ==> vf_num:0
+	 * 3. ethtool -U <netdev> ... vf <vf_idx> queue <queue_num>  ==>
+	 *    vf_num:vf_idx+1
+	 */
+	vf_num = ethtool_get_flow_spec_ring_vf(fsp->ring_cookie);
+	if (!is_otx2_vf(pfvf->pcifunc) && vf_num)
+		goto bypass_queue_check;
+
 	if (ring >= pfvf->hw.rx_queues && fsp->ring_cookie != RX_CLS_FLOW_DISC)
 		return -EINVAL;
 
+bypass_queue_check:
 	if (fsp->location >= otx2_get_maxflows(flow_cfg))
 		return -EINVAL;
 
@@ -1182,6 +1200,9 @@ int otx2_add_flow(struct otx2_nic *pfvf, struct ethtool_rxnfc *nfc)
 		flow_cfg->nr_flows++;
 	}
 
+	if (flow->is_vf)
+		netdev_info(pfvf->netdev,
+			    "Make sure that VF's queue number is within its queue limit\n");
 	return 0;
 }
 
-- 
2.25.1


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

* Re: [net PATCH] octeontx2-pf: Fix ntuple rule creation to direct packet to VF with higher Rx queue than its PF
  2023-11-20  5:51 [net PATCH] octeontx2-pf: Fix ntuple rule creation to direct packet to VF with higher Rx queue than its PF Suman Ghosh
@ 2023-11-20 12:02 ` Wojciech Drewek
  2023-11-21  9:54   ` [EXT] " Suman Ghosh
  0 siblings, 1 reply; 5+ messages in thread
From: Wojciech Drewek @ 2023-11-20 12:02 UTC (permalink / raw)
  To: Suman Ghosh, sgoutham, gakula, sbhatta, hkelam, lcherian, jerinj,
	davem, edumazet, kuba, pabeni, netdev, linux-kernel, horms



On 20.11.2023 06:51, Suman Ghosh wrote:
> It is possible to add a ntuple rule which would like to direct packet to
> a VF whose number of queues are greater/less than its PF's queue numbers.
> For example a PF can have 2 Rx queues but a VF created on that PF can have
> 8 Rx queues. As of today, ntuple rule will reject rule because it is
> checking the requested queue number against PF's number of Rx queues.
> As a part of this fix if the action of a ntuple rule is to move a packet
> to a VF's queue then the check is removed. Also, a debug information is
> printed to aware user that it is user's responsibility to cross check if
> the requested queue number on that VF is a valid one.
> 
> Fixes: f0a1913f8a6f ("octeontx2-pf: Add support for ethtool ntuple filters")
> Signed-off-by: Suman Ghosh <sumang@marvell.com>
> ---
>  .../marvell/octeontx2/nic/otx2_flows.c        | 21 +++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
> index 4762dbea64a1..4200f2d387f6 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
> @@ -1088,6 +1088,7 @@ int otx2_add_flow(struct otx2_nic *pfvf, struct ethtool_rxnfc *nfc)
>  	struct ethhdr *eth_hdr;
>  	bool new = false;
>  	int err = 0;
> +	u64 vf_num;
>  	u32 ring;
>  
>  	if (!flow_cfg->max_flows) {
> @@ -1100,9 +1101,26 @@ int otx2_add_flow(struct otx2_nic *pfvf, struct ethtool_rxnfc *nfc)
>  	if (!(pfvf->flags & OTX2_FLAG_NTUPLE_SUPPORT))
>  		return -ENOMEM;
>  
> +	/* Number of queues on a VF can be greater or less than
> +	 * the PF's queue. Hence no need to check for the
> +	 * queue count. Hence no need to check queue count if PF
> +	 * is installing for its VF. Below is the expected vf_num value
> +	 * based on the ethtool commands.
> +	 *
> +	 * e.g.
> +	 * 1. ethtool -U <netdev> ... action -1  ==> vf_num:255
> +	 * 2. ethtool -U <netdev> ... action <queue_num>  ==> vf_num:0
> +	 * 3. ethtool -U <netdev> ... vf <vf_idx> queue <queue_num>  ==>
> +	 *    vf_num:vf_idx+1
> +	 */
> +	vf_num = ethtool_get_flow_spec_ring_vf(fsp->ring_cookie);
> +	if (!is_otx2_vf(pfvf->pcifunc) && vf_num)
> +		goto bypass_queue_check;

Let's just add this condition to the next if, no need for goto.

> +
>  	if (ring >= pfvf->hw.rx_queues && fsp->ring_cookie != RX_CLS_FLOW_DISC)
>  		return -EINVAL;
>  
> +bypass_queue_check:
>  	if (fsp->location >= otx2_get_maxflows(flow_cfg))
>  		return -EINVAL;
>  
> @@ -1182,6 +1200,9 @@ int otx2_add_flow(struct otx2_nic *pfvf, struct ethtool_rxnfc *nfc)
>  		flow_cfg->nr_flows++;
>  	}
>  
> +	if (flow->is_vf)
> +		netdev_info(pfvf->netdev,
> +			    "Make sure that VF's queue number is within its queue limit\n");
>  	return 0;
>  }
>  

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

* RE: [EXT] Re: [net PATCH] octeontx2-pf: Fix ntuple rule creation to direct packet to VF with higher Rx queue than its PF
  2023-11-20 12:02 ` Wojciech Drewek
@ 2023-11-21  9:54   ` Suman Ghosh
  2023-11-21 15:55     ` Simon Horman
  0 siblings, 1 reply; 5+ messages in thread
From: Suman Ghosh @ 2023-11-21  9:54 UTC (permalink / raw)
  To: Wojciech Drewek, Sunil Kovvuri Goutham, Geethasowjanya Akula,
	Subbaraya Sundeep Bhatta, Hariprasad Kelam, Linu Cherian,
	Jerin Jacob Kollanukkaran, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, horms

>> Signed-off-by: Suman Ghosh <sumang@marvell.com>
>> ---
>>  .../marvell/octeontx2/nic/otx2_flows.c        | 21
>+++++++++++++++++++
>>  1 file changed, 21 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
>> b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
>> index 4762dbea64a1..4200f2d387f6 100644
>> --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
>> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
>> @@ -1088,6 +1088,7 @@ int otx2_add_flow(struct otx2_nic *pfvf, struct
>ethtool_rxnfc *nfc)
>>  	struct ethhdr *eth_hdr;
>>  	bool new = false;
>>  	int err = 0;
>> +	u64 vf_num;
>>  	u32 ring;
>>
>>  	if (!flow_cfg->max_flows) {
>> @@ -1100,9 +1101,26 @@ int otx2_add_flow(struct otx2_nic *pfvf, struct
>ethtool_rxnfc *nfc)
>>  	if (!(pfvf->flags & OTX2_FLAG_NTUPLE_SUPPORT))
>>  		return -ENOMEM;
>>
>> +	/* Number of queues on a VF can be greater or less than
>> +	 * the PF's queue. Hence no need to check for the
>> +	 * queue count. Hence no need to check queue count if PF
>> +	 * is installing for its VF. Below is the expected vf_num value
>> +	 * based on the ethtool commands.
>> +	 *
>> +	 * e.g.
>> +	 * 1. ethtool -U <netdev> ... action -1  ==> vf_num:255
>> +	 * 2. ethtool -U <netdev> ... action <queue_num>  ==> vf_num:0
>> +	 * 3. ethtool -U <netdev> ... vf <vf_idx> queue <queue_num>  ==>
>> +	 *    vf_num:vf_idx+1
>> +	 */
>> +	vf_num = ethtool_get_flow_spec_ring_vf(fsp->ring_cookie);
>> +	if (!is_otx2_vf(pfvf->pcifunc) && vf_num)
>> +		goto bypass_queue_check;
>
>Let's just add this condition to the next if, no need for goto.
[Suman] I kept it a separate check to make the code more readable. Otherwise the next if condition will be complicated.
>
>> +
>>  	if (ring >= pfvf->hw.rx_queues && fsp->ring_cookie !=
>RX_CLS_FLOW_DISC)
>>  		return -EINVAL;
>>
>> +bypass_queue_check:
>>  	if (fsp->location >= otx2_get_maxflows(flow_cfg))
>>  		return -EINVAL;
>>
>> @@ -1182,6 +1200,9 @@ int otx2_add_flow(struct otx2_nic *pfvf, struct
>ethtool_rxnfc *nfc)
>>  		flow_cfg->nr_flows++;
>>  	}
>>
>> +	if (flow->is_vf)
>> +		netdev_info(pfvf->netdev,
>> +			    "Make sure that VF's queue number is within its queue
>> +limit\n");
>>  	return 0;
>>  }
>>

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

* Re: [EXT] Re: [net PATCH] octeontx2-pf: Fix ntuple rule creation to direct packet to VF with higher Rx queue than its PF
  2023-11-21  9:54   ` [EXT] " Suman Ghosh
@ 2023-11-21 15:55     ` Simon Horman
  2023-11-21 16:20       ` Suman Ghosh
  0 siblings, 1 reply; 5+ messages in thread
From: Simon Horman @ 2023-11-21 15:55 UTC (permalink / raw)
  To: Suman Ghosh
  Cc: Wojciech Drewek, Sunil Kovvuri Goutham, Geethasowjanya Akula,
	Subbaraya Sundeep Bhatta, Hariprasad Kelam, Linu Cherian,
	Jerin Jacob Kollanukkaran, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel

On Tue, Nov 21, 2023 at 09:54:00AM +0000, Suman Ghosh wrote:
> >> Signed-off-by: Suman Ghosh <sumang@marvell.com>
> >> ---
> >>  .../marvell/octeontx2/nic/otx2_flows.c        | 21
> >+++++++++++++++++++
> >>  1 file changed, 21 insertions(+)
> >>
> >> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
> >> b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
> >> index 4762dbea64a1..4200f2d387f6 100644
> >> --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
> >> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
> >> @@ -1088,6 +1088,7 @@ int otx2_add_flow(struct otx2_nic *pfvf, struct
> >ethtool_rxnfc *nfc)
> >>  	struct ethhdr *eth_hdr;
> >>  	bool new = false;
> >>  	int err = 0;
> >> +	u64 vf_num;
> >>  	u32 ring;
> >>
> >>  	if (!flow_cfg->max_flows) {
> >> @@ -1100,9 +1101,26 @@ int otx2_add_flow(struct otx2_nic *pfvf, struct
> >ethtool_rxnfc *nfc)
> >>  	if (!(pfvf->flags & OTX2_FLAG_NTUPLE_SUPPORT))
> >>  		return -ENOMEM;
> >>
> >> +	/* Number of queues on a VF can be greater or less than
> >> +	 * the PF's queue. Hence no need to check for the
> >> +	 * queue count. Hence no need to check queue count if PF
> >> +	 * is installing for its VF. Below is the expected vf_num value
> >> +	 * based on the ethtool commands.
> >> +	 *
> >> +	 * e.g.
> >> +	 * 1. ethtool -U <netdev> ... action -1  ==> vf_num:255
> >> +	 * 2. ethtool -U <netdev> ... action <queue_num>  ==> vf_num:0
> >> +	 * 3. ethtool -U <netdev> ... vf <vf_idx> queue <queue_num>  ==>
> >> +	 *    vf_num:vf_idx+1
> >> +	 */
> >> +	vf_num = ethtool_get_flow_spec_ring_vf(fsp->ring_cookie);
> >> +	if (!is_otx2_vf(pfvf->pcifunc) && vf_num)
> >> +		goto bypass_queue_check;
> >
> >Let's just add this condition to the next if, no need for goto.
> [Suman] I kept it a separate check to make the code more readable. Otherwise the next if condition will be complicated.

Readability is subjective, but, FWIIW, I'd also prefer
to avoid a goto here.

> >> +
> >>  	if (ring >= pfvf->hw.rx_queues && fsp->ring_cookie !=
> >RX_CLS_FLOW_DISC)
> >>  		return -EINVAL;
> >>
> >> +bypass_queue_check:
> >>  	if (fsp->location >= otx2_get_maxflows(flow_cfg))
> >>  		return -EINVAL;
> >>
> >> @@ -1182,6 +1200,9 @@ int otx2_add_flow(struct otx2_nic *pfvf, struct
> >ethtool_rxnfc *nfc)
> >>  		flow_cfg->nr_flows++;
> >>  	}
> >>
> >> +	if (flow->is_vf)
> >> +		netdev_info(pfvf->netdev,
> >> +			    "Make sure that VF's queue number is within its queue
> >> +limit\n");
> >>  	return 0;
> >>  }
> >>

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

* RE: [EXT] Re: [net PATCH] octeontx2-pf: Fix ntuple rule creation to direct packet to VF with higher Rx queue than its PF
  2023-11-21 15:55     ` Simon Horman
@ 2023-11-21 16:20       ` Suman Ghosh
  0 siblings, 0 replies; 5+ messages in thread
From: Suman Ghosh @ 2023-11-21 16:20 UTC (permalink / raw)
  To: Simon Horman
  Cc: Wojciech Drewek, Sunil Kovvuri Goutham, Geethasowjanya Akula,
	Subbaraya Sundeep Bhatta, Hariprasad Kelam, Linu Cherian,
	Jerin Jacob Kollanukkaran, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel

>> >ethtool_rxnfc *nfc)
>> >>  	struct ethhdr *eth_hdr;
>> >>  	bool new = false;
>> >>  	int err = 0;
>> >> +	u64 vf_num;
>> >>  	u32 ring;
>> >>
>> >>  	if (!flow_cfg->max_flows) {
>> >> @@ -1100,9 +1101,26 @@ int otx2_add_flow(struct otx2_nic *pfvf,
>> >> struct
>> >ethtool_rxnfc *nfc)
>> >>  	if (!(pfvf->flags & OTX2_FLAG_NTUPLE_SUPPORT))
>> >>  		return -ENOMEM;
>> >>
>> >> +	/* Number of queues on a VF can be greater or less than
>> >> +	 * the PF's queue. Hence no need to check for the
>> >> +	 * queue count. Hence no need to check queue count if PF
>> >> +	 * is installing for its VF. Below is the expected vf_num
>value
>> >> +	 * based on the ethtool commands.
>> >> +	 *
>> >> +	 * e.g.
>> >> +	 * 1. ethtool -U <netdev> ... action -1  ==> vf_num:255
>> >> +	 * 2. ethtool -U <netdev> ... action <queue_num>  ==> vf_num:0
>> >> +	 * 3. ethtool -U <netdev> ... vf <vf_idx> queue <queue_num>
>==>
>> >> +	 *    vf_num:vf_idx+1
>> >> +	 */
>> >> +	vf_num = ethtool_get_flow_spec_ring_vf(fsp->ring_cookie);
>> >> +	if (!is_otx2_vf(pfvf->pcifunc) && vf_num)
>> >> +		goto bypass_queue_check;
>> >
>> >Let's just add this condition to the next if, no need for goto.
>> [Suman] I kept it a separate check to make the code more readable.
>Otherwise the next if condition will be complicated.
>
>Readability is subjective, but, FWIIW, I'd also prefer to avoid a goto
>here.
[Suman] Okay. Since both of you are suggesting the same change, I will update the same in v2.
>
>> >> +
>> >>  	if (ring >= pfvf->hw.rx_queues && fsp->ring_cookie !=
>> >RX_CLS_FLOW_DISC)
>> >>  		return -EINVAL;
>> >>
>> >> +bypass_queue_check:
>> >>  	if (fsp->location >= otx2_get_maxflows(flow_cfg))
>> >>  		return -EINVAL;
>> >>
>> >> @@ -1182,6 +1200,9 @@ int otx2_add_flow(struct otx2_nic *pfvf,
>> >> struct
>> >ethtool_rxnfc *nfc)
>> >>  		flow_cfg->nr_flows++;
>> >>  	}
>> >>
>> >> +	if (flow->is_vf)
>> >> +		netdev_info(pfvf->netdev,
>> >> +			    "Make sure that VF's queue number is within its
>queue
>> >> +limit\n");
>> >>  	return 0;
>> >>  }
>> >>

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

end of thread, other threads:[~2023-11-21 16:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-20  5:51 [net PATCH] octeontx2-pf: Fix ntuple rule creation to direct packet to VF with higher Rx queue than its PF Suman Ghosh
2023-11-20 12:02 ` Wojciech Drewek
2023-11-21  9:54   ` [EXT] " Suman Ghosh
2023-11-21 15:55     ` Simon Horman
2023-11-21 16:20       ` Suman Ghosh

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