Skip to content

Commit 9dbc8d2

Browse files
pieterj-xilinxdavem330
authored andcommitted
sfc: add decrement ipv6 hop limit by offloading set hop limit actions
Offload pedit set ipv6 hop limit, where the hop limit has already been matched and the new value is one less, by translating it to a decrement. 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 66f7288 commit 9dbc8d2

File tree

1 file changed

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

1 file changed

+59
-0
lines changed

drivers/net/ethernet/sfc/tc.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ enum efx_encap_type efx_tc_indr_netdev_type(struct net_device *net_dev)
3232
}
3333

3434
#define EFX_TC_HDR_TYPE_TTL_MASK ((u32)0xff)
35+
/* Hoplimit is stored in the most significant byte in the pedit ipv6 header action */
36+
#define EFX_TC_HDR_TYPE_HLIMIT_MASK ~((u32)0xff000000)
3537
#define EFX_EFV_PF NULL
3638
/* Look up the representor information (efv) for a device.
3739
* May return NULL for the PF (us), or an error pointer for a device that
@@ -1190,6 +1192,63 @@ static int efx_tc_mangle(struct efx_nic *efx, struct efx_tc_action_set *act,
11901192
return -EOPNOTSUPP;
11911193
}
11921194
break;
1195+
case FLOW_ACT_MANGLE_HDR_TYPE_IP6:
1196+
switch (fa->mangle.offset) {
1197+
case round_down(offsetof(struct ipv6hdr, hop_limit), 4):
1198+
/* we currently only support pedit IP6 when it applies
1199+
* to the hoplimit and then only when it can be achieved
1200+
* with a decrement hoplimit action
1201+
*/
1202+
1203+
/* check that pedit applies to ttl only */
1204+
if (fa->mangle.mask != EFX_TC_HDR_TYPE_HLIMIT_MASK) {
1205+
NL_SET_ERR_MSG_FMT_MOD(extack,
1206+
"Unsupported: mask (%#x) out of range, only support mangle action on ipv6.hop_limit",
1207+
fa->mangle.mask);
1208+
1209+
return -EOPNOTSUPP;
1210+
}
1211+
1212+
/* we can only convert to a dec ttl when we have an
1213+
* exact match on the ttl field
1214+
*/
1215+
if (match->mask.ip_ttl != U8_MAX) {
1216+
NL_SET_ERR_MSG_FMT_MOD(extack,
1217+
"Unsupported: only support mangle ipv6.hop_limit when we have an exact match on ttl, mask used for match (%#x)",
1218+
match->mask.ip_ttl);
1219+
return -EOPNOTSUPP;
1220+
}
1221+
1222+
/* check that we don't try to decrement 0, which equates
1223+
* to setting the ttl to 0xff
1224+
*/
1225+
if (match->value.ip_ttl == 0) {
1226+
NL_SET_ERR_MSG_MOD(extack,
1227+
"Unsupported: we cannot decrement hop_limit past 0");
1228+
return -EOPNOTSUPP;
1229+
}
1230+
1231+
/* check that we do not decrement hoplimit twice */
1232+
if (!efx_tc_flower_action_order_ok(act,
1233+
EFX_TC_AO_DEC_TTL)) {
1234+
NL_SET_ERR_MSG_MOD(extack,
1235+
"Unsupported: multiple dec ttl");
1236+
return -EOPNOTSUPP;
1237+
}
1238+
1239+
/* check pedit can be achieved with decrement action */
1240+
tr_ttl = match->value.ip_ttl - 1;
1241+
if ((fa->mangle.val >> 24) == tr_ttl) {
1242+
act->do_ttl_dec = 1;
1243+
return 0;
1244+
}
1245+
1246+
fallthrough;
1247+
default:
1248+
NL_SET_ERR_MSG_FMT_MOD(extack,
1249+
"Unsupported: only support mangle on the hop_limit field");
1250+
return -EOPNOTSUPP;
1251+
}
11931252
default:
11941253
NL_SET_ERR_MSG_FMT_MOD(extack, "Unhandled mangle htype %u for action rule",
11951254
fa->mangle.htype);

0 commit comments

Comments
 (0)