Commit 6c40ca95 authored by Geetha sowjanya's avatar Geetha sowjanya Committed by David S. Miller
Browse files

octeontx2-pf: Adds TC offload support



Implements tc offload support for rvu representors.

Usage example:

 - Add tc rule to drop packets with vlan id 3 using port
   representor(Rpf1vf0).

	# tc filter add dev Rpf1vf0 protocol 802.1Q parent ffff: flower
	   vlan_id 3 vlan_ethtype ipv4 skip_sw action drop

- Redirect packets with vlan id 5 and IPv4 packets to eth1,
  after stripping vlan header.

	# tc filter add dev Rpf1vf0 ingress protocol 802.1Q flower vlan_id 5
	  vlan_ethtype ipv4 skip_sw action vlan pop action mirred ingress
	  redirect dev eth1

Signed-off-by: default avatarGeetha sowjanya <gakula@marvell.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d8dec30b
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -1398,6 +1398,7 @@ int rvu_mbox_handler_npc_install_flow(struct rvu *rvu,
				      struct npc_install_flow_rsp *rsp)
{
	bool from_vf = !!(req->hdr.pcifunc & RVU_PFVF_FUNC_MASK);
	bool from_rep_dev = !!is_rep_dev(rvu, req->hdr.pcifunc);
	struct rvu_switch *rswitch = &rvu->rswitch;
	int blkaddr, nixlf, err;
	struct rvu_pfvf *pfvf;
@@ -1454,14 +1455,19 @@ int rvu_mbox_handler_npc_install_flow(struct rvu *rvu,
	/* AF installing for a PF/VF */
	if (!req->hdr.pcifunc)
		target = req->vf;

	/* PF installing for its VF */
	else if (!from_vf && req->vf) {
	if (!from_vf && req->vf && !from_rep_dev) {
		target = (req->hdr.pcifunc & ~RVU_PFVF_FUNC_MASK) | req->vf;
		pf_set_vfs_mac = req->default_rule &&
				(req->features & BIT_ULL(NPC_DMAC));
	}
	/* msg received from PF/VF */

	/* Representor device installing for a representee */
	if (from_rep_dev && req->vf)
		target = req->vf;
	else
		/* msg received from PF/VF */
		target = req->hdr.pcifunc;

	/* ignore chan_mask in case pf func is not AF, revisit later */
@@ -1474,8 +1480,10 @@ int rvu_mbox_handler_npc_install_flow(struct rvu *rvu,

	pfvf = rvu_get_pfvf(rvu, target);

	if (from_rep_dev)
		req->channel = pfvf->rx_chan_base;
	/* PF installing for its VF */
	if (req->hdr.pcifunc && !from_vf && req->vf)
	if (req->hdr.pcifunc && !from_vf && req->vf && !from_rep_dev)
		set_bit(PF_SET_VF_CFG, &pfvf->flags);

	/* update req destination mac addr */
+4 −0
Original line number Diff line number Diff line
@@ -427,6 +427,10 @@ int rvu_mbox_handler_esw_cfg(struct rvu *rvu, struct esw_cfg_req *req,
		return 0;

	rvu->rep_mode = req->ena;

	if (!rvu->rep_mode)
		rvu_npc_free_mcam_entries(rvu, req->hdr.pcifunc, -1);

	return 0;
}

+7 −0
Original line number Diff line number Diff line
@@ -1142,4 +1142,11 @@ int otx2_get_txq_by_classid(struct otx2_nic *pfvf, u16 classid);
void otx2_qos_config_txschq(struct otx2_nic *pfvf);
void otx2_clean_qos_queues(struct otx2_nic *pfvf);
int rvu_event_up_notify(struct otx2_nic *pf, struct rep_event *info);
int otx2_setup_tc_cls_flower(struct otx2_nic *nic,
			     struct flow_cls_offload *cls_flower);

static inline int mcam_entry_cmp(const void *a, const void *b)
{
	return *(u16 *)a - *(u16 *)b;
}
#endif /* OTX2_COMMON_H */
+0 −5
Original line number Diff line number Diff line
@@ -64,11 +64,6 @@ static int otx2_free_ntuple_mcam_entries(struct otx2_nic *pfvf)
	return 0;
}

static int mcam_entry_cmp(const void *a, const void *b)
{
	return *(u16 *)a - *(u16 *)b;
}

int otx2_alloc_mcam_entries(struct otx2_nic *pfvf, u16 count)
{
	struct otx2_flow_config *flow_cfg = pfvf->flow_cfg;
+16 −9
Original line number Diff line number Diff line
@@ -443,6 +443,7 @@ static int otx2_tc_parse_actions(struct otx2_nic *nic,
	struct flow_action_entry *act;
	struct net_device *target;
	struct otx2_nic *priv;
	struct rep_dev *rdev;
	u32 burst, mark = 0;
	u8 nr_police = 0;
	u8 num_intf = 1;
@@ -464,14 +465,18 @@ static int otx2_tc_parse_actions(struct otx2_nic *nic,
			return 0;
		case FLOW_ACTION_REDIRECT_INGRESS:
			target = act->dev;
			if (target->dev.parent) {
				priv = netdev_priv(target);
			/* npc_install_flow_req doesn't support passing a target pcifunc */
				if (rvu_get_pf(nic->pcifunc) != rvu_get_pf(priv->pcifunc)) {
					NL_SET_ERR_MSG_MOD(extack,
							   "can't redirect to other pf/vf");
					return -EOPNOTSUPP;
				}
				req->vf = priv->pcifunc & RVU_PFVF_FUNC_MASK;
			} else {
				rdev = netdev_priv(target);
				req->vf = rdev->pcifunc & RVU_PFVF_FUNC_MASK;
			}

			/* if op is already set; avoid overwriting the same */
			if (!req->op)
@@ -1300,6 +1305,7 @@ static int otx2_tc_add_flow(struct otx2_nic *nic,
	req->channel = nic->hw.rx_chan_base;
	req->entry = flow_cfg->flow_ent[mcam_idx];
	req->intf = NIX_INTF_RX;
	req->vf = nic->pcifunc;
	req->set_cntr = 1;
	new_node->entry = req->entry;

@@ -1400,7 +1406,7 @@ static int otx2_tc_get_flow_stats(struct otx2_nic *nic,
	return 0;
}

static int otx2_setup_tc_cls_flower(struct otx2_nic *nic,
int otx2_setup_tc_cls_flower(struct otx2_nic *nic,
			     struct flow_cls_offload *cls_flower)
{
	switch (cls_flower->command) {
@@ -1414,6 +1420,7 @@ static int otx2_setup_tc_cls_flower(struct otx2_nic *nic,
		return -EOPNOTSUPP;
	}
}
EXPORT_SYMBOL(otx2_setup_tc_cls_flower);

static int otx2_tc_ingress_matchall_install(struct otx2_nic *nic,
					    struct tc_cls_matchall_offload *cls)
Loading