Skip to content

Commit 6a57f09

Browse files
Geetha sowjanyadavem330
authored andcommitted
octeontx2-pf: Add support for offload tc with skbedit mark action
Support offloading of skbedit mark action. For example, to mark with 0x0008, with dest ip 60.60.60.2 on eth2 interface: # tc qdisc add dev eth2 ingress # tc filter add dev eth2 ingress protocol ip flower \ dst_ip 60.60.60.2 action skbedit mark 0x0008 skip_sw Signed-off-by: Geetha sowjanya <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 80b7aae commit 6a57f09

File tree

6 files changed

+24
-0
lines changed

6 files changed

+24
-0
lines changed

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,8 @@ static int npc_update_rx_entry(struct rvu *rvu, struct rvu_pfvf *pfvf,
11871187
action.pf_func = target;
11881188
action.op = NIX_RX_ACTIONOP_UCAST;
11891189
}
1190+
if (req->match_id)
1191+
action.match_id = req->match_id;
11901192
}
11911193

11921194
entry->action = *(u64 *)&action;

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ struct otx2_flow_config {
363363
struct list_head flow_list;
364364
u32 dmacflt_max_flows;
365365
u16 max_flows;
366+
refcount_t mark_flows;
366367
struct list_head flow_list_tc;
367368
bool ntuple;
368369
};
@@ -465,6 +466,7 @@ struct otx2_nic {
465466
#define OTX2_FLAG_DMACFLTR_SUPPORT BIT_ULL(14)
466467
#define OTX2_FLAG_PTP_ONESTEP_SYNC BIT_ULL(15)
467468
#define OTX2_FLAG_ADPTV_INT_COAL_ENABLED BIT_ULL(16)
469+
#define OTX2_FLAG_TC_MARK_ENABLED BIT_ULL(17)
468470
u64 flags;
469471
u64 *cq_op_addr;
470472

drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ static int otx2_mcam_entry_init(struct otx2_nic *pfvf)
252252

253253
pfvf->flags |= OTX2_FLAG_TC_FLOWER_SUPPORT;
254254

255+
refcount_set(&flow_cfg->mark_flows, 1);
255256
return 0;
256257
}
257258

drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,15 @@ static int otx2_tc_parse_actions(struct otx2_nic *nic,
511511
nr_police++;
512512
break;
513513
case FLOW_ACTION_MARK:
514+
if (act->mark & ~OTX2_RX_MATCH_ID_MASK) {
515+
NL_SET_ERR_MSG_MOD(extack, "Bad flow mark, only 16 bit supported");
516+
return -EOPNOTSUPP;
517+
}
514518
mark = act->mark;
519+
req->match_id = mark & OTX2_RX_MATCH_ID_MASK;
520+
req->op = NIX_RX_ACTION_DEFAULT;
521+
nic->flags |= OTX2_FLAG_TC_MARK_ENABLED;
522+
refcount_inc(&nic->flow_cfg->mark_flows);
515523
break;
516524

517525
case FLOW_ACTION_RX_QUEUE_MAPPING:
@@ -1187,6 +1195,11 @@ static int otx2_tc_del_flow(struct otx2_nic *nic,
11871195
return -EINVAL;
11881196
}
11891197

1198+
/* Disable TC MARK flag if they are no rules with skbedit mark action */
1199+
if (flow_node->req.match_id)
1200+
if (!refcount_dec_and_test(&flow_cfg->mark_flows))
1201+
nic->flags &= ~OTX2_FLAG_TC_MARK_ENABLED;
1202+
11901203
if (flow_node->is_act_police) {
11911204
__clear_bit(flow_node->rq, &nic->rq_bmap);
11921205

drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,9 @@ static void otx2_rcv_pkt_handler(struct otx2_nic *pfvf,
380380
if (pfvf->netdev->features & NETIF_F_RXCSUM)
381381
skb->ip_summed = CHECKSUM_UNNECESSARY;
382382

383+
if (pfvf->flags & OTX2_FLAG_TC_MARK_ENABLED)
384+
skb->mark = parse->match_id;
385+
383386
skb_mark_for_recycle(skb);
384387

385388
napi_gro_frags(napi);

drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
#define CQ_OP_STAT_OP_ERR 63
6363
#define CQ_OP_STAT_CQ_ERR 46
6464

65+
/* Packet mark mask */
66+
#define OTX2_RX_MATCH_ID_MASK 0x0000ffff
67+
6568
struct queue_stats {
6669
u64 bytes;
6770
u64 pkts;

0 commit comments

Comments
 (0)