Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: macsec: add support for specifying offload upon link creation

This patch adds new netlink attribute to allow a user to (optionally)
specify the desired offload mode immediately upon MACSec link creation.

Separate iproute patch will be required to support this from user space.

Signed-off-by: Mark Starovoytov <mstarovoitov@marvell.com>
Signed-off-by: Igor Russkikh <irusskikh@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Mark Starovoytov and committed by
David S. Miller
791bb3fc f0b59897

+31 -2
+29 -2
drivers/net/macsec.c
··· 1469 1469 return dev; 1470 1470 } 1471 1471 1472 + static enum macsec_offload nla_get_offload(const struct nlattr *nla) 1473 + { 1474 + return (__force enum macsec_offload)nla_get_u8(nla); 1475 + } 1476 + 1472 1477 static sci_t nla_get_sci(const struct nlattr *nla) 1473 1478 { 1474 1479 return (__force sci_t)nla_get_u64(nla); ··· 4017 4012 4018 4013 macsec->real_dev = real_dev; 4019 4014 4020 - /* MACsec offloading is off by default */ 4021 - macsec->offload = MACSEC_OFFLOAD_OFF; 4015 + if (data && data[IFLA_MACSEC_OFFLOAD]) 4016 + macsec->offload = nla_get_offload(data[IFLA_MACSEC_OFFLOAD]); 4017 + else 4018 + /* MACsec offloading is off by default */ 4019 + macsec->offload = MACSEC_OFFLOAD_OFF; 4020 + 4021 + /* Check if the offloading mode is supported by the underlying layers */ 4022 + if (macsec->offload != MACSEC_OFFLOAD_OFF && 4023 + !macsec_check_offload(macsec->offload, macsec)) 4024 + return -EOPNOTSUPP; 4022 4025 4023 4026 if (data && data[IFLA_MACSEC_ICV_LEN]) 4024 4027 icv_len = nla_get_u8(data[IFLA_MACSEC_ICV_LEN]); ··· 4067 4054 err = macsec_changelink_common(dev, data); 4068 4055 if (err) 4069 4056 goto del_dev; 4057 + } 4058 + 4059 + /* If h/w offloading is available, propagate to the device */ 4060 + if (macsec_is_offloaded(macsec)) { 4061 + const struct macsec_ops *ops; 4062 + struct macsec_context ctx; 4063 + 4064 + ops = macsec_get_ops(macsec, &ctx); 4065 + if (ops) { 4066 + ctx.secy = &macsec->secy; 4067 + err = macsec_offload(ops->mdo_add_secy, &ctx); 4068 + if (err) 4069 + goto del_dev; 4070 + } 4070 4071 } 4071 4072 4072 4073 err = register_macsec_dev(real_dev, dev);
+1
include/uapi/linux/if_link.h
··· 463 463 IFLA_MACSEC_REPLAY_PROTECT, 464 464 IFLA_MACSEC_VALIDATION, 465 465 IFLA_MACSEC_PAD, 466 + IFLA_MACSEC_OFFLOAD, 466 467 __IFLA_MACSEC_MAX, 467 468 }; 468 469
+1
tools/include/uapi/linux/if_link.h
··· 463 463 IFLA_MACSEC_REPLAY_PROTECT, 464 464 IFLA_MACSEC_VALIDATION, 465 465 IFLA_MACSEC_PAD, 466 + IFLA_MACSEC_OFFLOAD, 466 467 __IFLA_MACSEC_MAX, 467 468 }; 468 469