Skip to content

Commit

Permalink
cxgb4: add tc flower support for ETH-SMAC rewrite
Browse files Browse the repository at this point in the history
Adds support for ETH-SMAC rewrite via TC-PEDIT action.

Signed-off-by: Kumar Sanghvi <kumaras@chelsio.com>
Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Signed-off-by: Ganesh Goudar <ganeshgr@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Kumar Sanghvi authored and David S. Miller committed Oct 20, 2017
1 parent 3bdb376 commit 202187c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
struct ch_tc_pedit_fields pedits[] = {
PEDIT_FIELDS(ETH_, DMAC_31_0, 4, dmac, 0),
PEDIT_FIELDS(ETH_, DMAC_47_32, 2, dmac, 4),
PEDIT_FIELDS(ETH_, SMAC_15_0, 2, smac, 0),
PEDIT_FIELDS(ETH_, SMAC_47_16, 4, smac, 2),
};

static struct ch_tc_flower_entry *allocate_flower_entry(void)
Expand Down Expand Up @@ -291,6 +293,13 @@ static void process_pedit_field(struct ch_filter_specification *fs, u32 val,
case PEDIT_ETH_DMAC_47_32_SMAC_15_0:
if (~mask & PEDIT_ETH_DMAC_MASK)
offload_pedit(fs, val, mask, ETH_DMAC_47_32);
else
offload_pedit(fs, val >> 16, mask >> 16,
ETH_SMAC_15_0);
break;
case PEDIT_ETH_SMAC_47_16:
fs->newsmac = 1;
offload_pedit(fs, val, mask, ETH_SMAC_47_16);
}
}
}
Expand Down Expand Up @@ -440,6 +449,7 @@ static int cxgb4_validate_flow_actions(struct net_device *dev,
switch (offset) {
case PEDIT_ETH_DMAC_31_0:
case PEDIT_ETH_DMAC_47_32_SMAC_15_0:
case PEDIT_ETH_SMAC_47_16:
break;
default:
netdev_err(dev, "%s: Unsupported pedit field\n",
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ struct ch_tc_flower_entry {
enum {
ETH_DMAC_31_0, /* dmac bits 0.. 31 */
ETH_DMAC_47_32, /* dmac bits 32..47 */
ETH_SMAC_15_0, /* smac bits 0.. 15 */
ETH_SMAC_47_16, /* smac bits 16..47 */
};

struct ch_tc_pedit_fields {
Expand All @@ -72,6 +74,7 @@ struct ch_tc_pedit_fields {
#define PEDIT_ETH_DMAC_MASK 0xffff
#define PEDIT_ETH_DMAC_31_0 0x0
#define PEDIT_ETH_DMAC_47_32_SMAC_15_0 0x4
#define PEDIT_ETH_SMAC_47_16 0x8

int cxgb4_tc_flower_replace(struct net_device *dev,
struct tc_cls_flower_offload *cls);
Expand Down

0 comments on commit 202187c

Please sign in to comment.