All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Michael Chan <michael.chan@broadcom.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
	Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Subject: Re: [PATCH net-next 01/16] bnxt_en: Support ingress rate limiting with TC-offload.
Date: Sun, 26 Jan 2020 16:12:56 -0800	[thread overview]
Message-ID: <20200126161256.6cf37aad@cakuba> (raw)
In-Reply-To: <1580029390-32760-2-git-send-email-michael.chan@broadcom.com>

On Sun, 26 Jan 2020 04:02:55 -0500, Michael Chan wrote:
> From: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
> 
> This patch enables offloading of ingress rate limiting TC-action
> on a VF. The driver processes "cls_matchall" filter callbacks to
> add and remove ingress rate limiting actions. The driver parses
> police action parameter and sends the command to FW to configure
> rate limiting for the VF.
> 
> For example, to configure rate limiting offload on a VF using OVS,
> use the below command on the corresponding VF-rep port. The example
> below configures min and max tx rates of 200 and 600 Mbps.
> 
> 	# ovs-vsctl set interface bnxt0_pf0vf0 \
> 		ingress_policing_rate=600000 ingress_policing_burst=200000
> 
> Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
> Signed-off-by: Michael Chan <michael.chan@broadcom.com>

Does the device drop or back-pressure when VF goes over the rate?

> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> index f143354..534bc9e 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> @@ -1069,6 +1069,7 @@ struct bnxt_vf_info {
>  	u32	max_tx_rate;
>  	void	*hwrm_cmd_req_addr;
>  	dma_addr_t	hwrm_cmd_req_dma_addr;
> +	unsigned long police_id;
>  };
>  #endif
>  
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
> index 0cc6ec5..2dfb650 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
> @@ -10,6 +10,7 @@
>  #include <linux/netdevice.h>
>  #include <linux/inetdevice.h>
>  #include <linux/if_vlan.h>
> +#include <linux/pci.h>
>  #include <net/flow_dissector.h>
>  #include <net/pkt_cls.h>
>  #include <net/tc_act/tc_gact.h>
> @@ -1983,6 +1984,95 @@ static int bnxt_tc_indr_block_event(struct notifier_block *nb,
>  	return NOTIFY_DONE;
>  }
>  
> +static inline int bnxt_tc_find_vf_by_fid(struct bnxt *bp, u16 fid)

No static inlines in C files

> +{
> +	int num_vfs = pci_num_vf(bp->pdev);
> +	int i;
> +
> +	for (i = 0; i < num_vfs; i++) {
> +		if (bp->pf.vf[i].fw_fid == fid)

return i;

> +			break;
> +	}

return -EINVAL;

> +	if (i >= num_vfs)
> +		return -EINVAL;
> +	return i;
> +}

> +static int bnxt_tc_add_matchall(struct bnxt *bp, u16 src_fid,
> +				struct tc_cls_matchall_offload *matchall_cmd)
> +{
> +	struct flow_action_entry *action;
> +	int vf_idx;
> +	s64 burst;
> +	u64 rate;
> +	int rc;
> +
> +	vf_idx = bnxt_tc_find_vf_by_fid(bp, src_fid);
> +	if (vf_idx < 0)
> +		return vf_idx;

You need to check this is the only action, check priority, check
shared, etc. Just look as one of the drivers which do this right :/

> +	action = &matchall_cmd->rule->action.entries[0];
> +	if (action->id != FLOW_ACTION_POLICE) {
> +		netdev_err(bp->dev, "%s: Unsupported matchall action: %d",
> +			   __func__, action->id);
> +		return -EOPNOTSUPP;
> +	}
> +	if (bp->pf.vf[vf_idx].police_id && bp->pf.vf[vf_idx].police_id !=
> +	    matchall_cmd->cookie) {
> +		netdev_err(bp->dev,
> +			   "%s: Policer is already configured for VF: %d",
> +			   __func__, vf_idx);
> +		return -EEXIST;
> +	}
> +
> +	rate = (u32)div_u64(action->police.rate_bytes_ps, 1024 * 1000) * 8;
> +	burst = (u32)div_u64(action->police.rate_bytes_ps *
> +			     PSCHED_NS2TICKS(action->police.burst),
> +			     PSCHED_TICKS_PER_SEC);
> +	burst = (u32)PSCHED_TICKS2NS(burst) / (1 << 20);
> +
> +	rc = bnxt_set_vf_bw(bp->dev, vf_idx, burst, rate);
> +	if (rc) {
> +		netdev_err(bp->dev,
> +			   "Error: %s: VF: %d rate: %llu burst: %llu rc: %d",
> +			   __func__, vf_idx, rate, burst, rc);
> +		return rc;
> +	}
> +
> +	bp->pf.vf[vf_idx].police_id = matchall_cmd->cookie;
> +	return 0;
> +}
> +
> +int bnxt_tc_setup_matchall(struct bnxt *bp, u16 src_fid,
> +			   struct tc_cls_matchall_offload *cls_matchall)
> +{
> +	switch (cls_matchall->command) {
> +	case TC_CLSMATCHALL_REPLACE:
> +		return bnxt_tc_add_matchall(bp, src_fid, cls_matchall);
> +	case TC_CLSMATCHALL_DESTROY:
> +		return bnxt_tc_del_matchall(bp, src_fid, cls_matchall);
> +	default:
> +		return -EOPNOTSUPP;
> +	}
> +}
> +
>  static const struct rhashtable_params bnxt_tc_flow_ht_params = {
>  	.head_offset = offsetof(struct bnxt_tc_flow_node, node),
>  	.key_offset = offsetof(struct bnxt_tc_flow_node, cookie),
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.h
> index 10c62b0..963788e 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.h
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.h
> @@ -220,6 +220,9 @@ int bnxt_tc_setup_flower(struct bnxt *bp, u16 src_fid,
>  int bnxt_init_tc(struct bnxt *bp);
>  void bnxt_shutdown_tc(struct bnxt *bp);
>  void bnxt_tc_flow_stats_work(struct bnxt *bp);
> +int bnxt_tc_setup_matchall(struct bnxt *bp, u16 src_fid,
> +			   struct tc_cls_matchall_offload *cls_matchall);
> +
>  

Spurious new line

>  static inline bool bnxt_tc_flower_enabled(struct bnxt *bp)
>  {

  reply	other threads:[~2020-01-27  0:14 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-26  9:02 [PATCH net-next 00/16] bnxt_en: Updates for net-next Michael Chan
2020-01-26  9:02 ` [PATCH net-next 01/16] bnxt_en: Support ingress rate limiting with TC-offload Michael Chan
2020-01-27  0:12   ` Jakub Kicinski [this message]
2020-01-26  9:02 ` [PATCH net-next 02/16] bnxt_en: Improve link up detection Michael Chan
2020-01-26  9:02 ` [PATCH net-next 03/16] bnxt_en: Improve bnxt_probe_phy() Michael Chan
2020-01-26  9:02 ` [PATCH net-next 04/16] bnxt_en: Remove the setting of dev_port Michael Chan
2020-01-26  9:02 ` [PATCH net-next 05/16] bnxt_en: Support UDP RSS hashing on 575XX chips Michael Chan
2020-01-26  9:03 ` [PATCH net-next 06/16] bnxt_en: Do not accept fragments for aRFS flow steering Michael Chan
2020-01-26  9:03 ` [PATCH net-next 07/16] bnxt_en: Periodically check and remove aged-out ntuple filters Michael Chan
2020-01-26  9:03 ` [PATCH net-next 08/16] bnxt_en: Disable workaround for lost interrupts on 575XX B0 and newer chips Michael Chan
2020-01-26  9:03 ` [PATCH net-next 09/16] bnxt_en: Refactor bnxt_dl_register() Michael Chan
2020-01-26 11:32   ` Jiri Pirko
2020-01-27  4:51     ` Vasundhara Volam
2020-01-26  9:03 ` [PATCH net-next 10/16] bnxt_en: Register devlink irrespective of firmware spec version Michael Chan
2020-01-26  9:03 ` [PATCH net-next 11/16] bnxt_en: Move devlink_register before registering netdev Michael Chan
2020-01-26  9:03 ` [PATCH net-next 12/16] bnxt_en: Add support to update progress of flash update Michael Chan
2020-01-26  9:03 ` [PATCH net-next 13/16] bnxt_en: Rename switch_id to dsn Michael Chan
2020-01-26  9:03 ` [PATCH net-next 14/16] devlink: add macros for "fw.roce" and "board.nvm_cfg" Michael Chan
2020-01-27  0:18   ` Jakub Kicinski
2020-01-27  5:42     ` Vasundhara Volam
2020-01-27 14:25       ` Jakub Kicinski
2020-01-26  9:03 ` [PATCH net-next 15/16] bnxt_en: Add support for devlink info command Michael Chan
2020-01-26  9:03 ` [PATCH net-next 16/16] devlink: document devlink info versions reported by bnxt_en driver Michael Chan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200126161256.6cf37aad@cakuba \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=sriharsha.basavapatna@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.