Skip to content

Commit 64848f0

Browse files
pieterj-xilinxdavem330
authored andcommitted
sfc: introduce pedit add actions on the ipv4 ttl field
Introduce pedit add actions and use it to achieve decrement ttl offload. Decrement ttl can be achieved by adding 0xff to the ttl field. Co-developed-by: Edward Cree <[email protected]> Signed-off-by: Edward Cree <[email protected]> Signed-off-by: Pieter Jansen van Vuuren <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9dbc8d2 commit 64848f0

File tree

1 file changed

+46
-0
lines changed
  • drivers/net/ethernet/sfc

1 file changed

+46
-0
lines changed

drivers/net/ethernet/sfc/tc.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,47 @@ static int efx_tc_complete_mac_mangle(struct efx_nic *efx,
10541054
return 0;
10551055
}
10561056

1057+
static int efx_tc_pedit_add(struct efx_nic *efx, struct efx_tc_action_set *act,
1058+
const struct flow_action_entry *fa,
1059+
struct netlink_ext_ack *extack)
1060+
{
1061+
switch (fa->mangle.htype) {
1062+
case FLOW_ACT_MANGLE_HDR_TYPE_IP4:
1063+
switch (fa->mangle.offset) {
1064+
case offsetof(struct iphdr, ttl):
1065+
/* check that pedit applies to ttl only */
1066+
if (fa->mangle.mask != ~EFX_TC_HDR_TYPE_TTL_MASK)
1067+
break;
1068+
1069+
/* Adding 0xff is equivalent to decrementing the ttl.
1070+
* Other added values are not supported.
1071+
*/
1072+
if ((fa->mangle.val & EFX_TC_HDR_TYPE_TTL_MASK) != U8_MAX)
1073+
break;
1074+
1075+
/* check that we do not decrement ttl twice */
1076+
if (!efx_tc_flower_action_order_ok(act,
1077+
EFX_TC_AO_DEC_TTL)) {
1078+
NL_SET_ERR_MSG_MOD(extack, "Unsupported: multiple dec ttl");
1079+
return -EOPNOTSUPP;
1080+
}
1081+
act->do_ttl_dec = 1;
1082+
return 0;
1083+
default:
1084+
break;
1085+
}
1086+
break;
1087+
default:
1088+
break;
1089+
}
1090+
1091+
NL_SET_ERR_MSG_FMT_MOD(extack,
1092+
"Unsupported: ttl add action type %x %x %x/%x",
1093+
fa->mangle.htype, fa->mangle.offset,
1094+
fa->mangle.val, fa->mangle.mask);
1095+
return -EOPNOTSUPP;
1096+
}
1097+
10571098
/**
10581099
* efx_tc_mangle() - handle a single 32-bit (or less) pedit
10591100
* @efx: NIC we're installing a flow rule on
@@ -2014,6 +2055,11 @@ static int efx_tc_flower_replace(struct efx_nic *efx,
20142055
act->vlan_proto[act->vlan_push] = fa->vlan.proto;
20152056
act->vlan_push++;
20162057
break;
2058+
case FLOW_ACTION_ADD:
2059+
rc = efx_tc_pedit_add(efx, act, fa, extack);
2060+
if (rc < 0)
2061+
goto release;
2062+
break;
20172063
case FLOW_ACTION_MANGLE:
20182064
rc = efx_tc_mangle(efx, act, fa, &mung, extack, &match);
20192065
if (rc < 0)

0 commit comments

Comments
 (0)