This patch introduces gso_ipv4_max_size and gro_ipv4_max_size per device and adds netlink attributes for them, so that IPV4 BIG TCP can be guarded by a separate tunable in the next patch. To not break the old application using "gso/gro_max_size" for IPv4 GSO packets, this patch updates "gso/gro_ipv4_max_size" in netif_set_gso/gro_max_size() if the new size isn't greater than GSO_LEGACY_MAX_SIZE, so that nothing will change even if userspace doesn't realize the new netlink attributes.
Unified · Split
| @@ -1964,6 +1964,8 @@ enum netdev_ml_priv_type { · 1963 unmodified lines | ||
| 1964 | 1964 | * @gso_max_segs: Maximum number of segments that can be passed to the |
| 1965 | 1965 | * NIC for GSO |
| 1966 | 1966 | * @tso_max_segs: Device (as in HW) limit on the max TSO segment count |
| 1967 | + * @gso_ipv4_max_size: Maximum size of generic segmentation offload, | |
| 1968 | + * for IPv4. | |
| 1967 | 1969 | * |
| 1968 | 1970 | * @dcbnl_ops: Data Center Bridging netlink ops |
| 1969 | 1971 | * @num_tc: Number of traffic classes in the net device |
| @@ -2004,6 +2006,8 @@ enum netdev_ml_priv_type { · 34 unmodified lines | ||
| 2004 | 2006 | * keep a list of interfaces to be deleted. |
| 2005 | 2007 | * @gro_max_size: Maximum size of aggregated packet in generic |
| 2006 | 2008 | * receive offload (GRO) |
| 2009 | + * @gro_ipv4_max_size: Maximum size of aggregated packet in generic | |
| 2010 | + * receive offload (GRO), for IPv4. | |
| 2007 | 2011 | * |
| 2008 | 2012 | * @dev_addr_shadow: Copy of @dev_addr to catch direct writes. |
| 2009 | 2013 | * @linkwatch_dev_tracker: refcount tracker used by linkwatch. |
| @@ -2207,6 +2211,7 @@ struct net_device { · 197 unmodified lines | ||
| 2207 | 2211 | */ |
| 2208 | 2212 | #define GRO_MAX_SIZE (8 * 65535u) |
| 2209 | 2213 | unsigned int gro_max_size; |
| 2214 | + unsigned int gro_ipv4_max_size; | |
| 2210 | 2215 | rx_handler_func_t __rcu *rx_handler; |
| 2211 | 2216 | void __rcu *rx_handler_data; |
| 2212 | 2217 | |
| @@ -2330,6 +2335,7 @@ struct net_device { · 117 unmodified lines | ||
| 2330 | 2335 | u16 gso_max_segs; |
| 2331 | 2336 | #define TSO_MAX_SEGS U16_MAX |
| 2332 | 2337 | u16 tso_max_segs; |
| 2338 | + unsigned int gso_ipv4_max_size; | |
| 2333 | 2339 | |
| 2334 | 2340 | #ifdef CONFIG_DCB |
| 2335 | 2341 | const struct dcbnl_rtnl_ops *dcbnl_ops; |
| @@ -374,6 +374,9 @@ enum { · 373 unmodified lines | ||
| 374 | 374 | |
| 375 | 375 | IFLA_DEVLINK_PORT, |
| 376 | 376 | |
| 377 | + IFLA_GSO_IPV4_MAX_SIZE, | |
| 378 | + IFLA_GRO_IPV4_MAX_SIZE, | |
| 379 | + | |
| 377 | 380 | __IFLA_MAX |
| 378 | 381 | }; |
| 379 | 382 | |
| @@ -3001,6 +3001,8 @@ void netif_set_tso_max_size(struct net_device *dev, unsigned int size) · 3000 unmodified lines | ||
| 3001 | 3001 | dev->tso_max_size = min(GSO_MAX_SIZE, size); |
| 3002 | 3002 | if (size < READ_ONCE(dev->gso_max_size)) |
| 3003 | 3003 | netif_set_gso_max_size(dev, size); |
| 3004 | + if (size < READ_ONCE(dev->gso_ipv4_max_size)) | |
| 3005 | + netif_set_gso_ipv4_max_size(dev, size); | |
| 3004 | 3006 | } |
| 3005 | 3007 | EXPORT_SYMBOL(netif_set_tso_max_size); |
| 3006 | 3008 | |
| @@ -10614,6 +10616,8 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, · 7607 unmodified lines | ||
| 10614 | 10616 | dev->gso_max_size = GSO_LEGACY_MAX_SIZE; |
| 10615 | 10617 | dev->gso_max_segs = GSO_MAX_SEGS; |
| 10616 | 10618 | dev->gro_max_size = GRO_LEGACY_MAX_SIZE; |
| 10619 | + dev->gso_ipv4_max_size = GSO_LEGACY_MAX_SIZE; | |
| 10620 | + dev->gro_ipv4_max_size = GRO_LEGACY_MAX_SIZE; | |
| 10617 | 10621 | dev->tso_max_size = TSO_LEGACY_MAX_SIZE; |
| 10618 | 10622 | dev->tso_max_segs = TSO_MAX_SEGS; |
| 10619 | 10623 | dev->upper_level = 1; |
| @@ -100,6 +100,8 @@ static inline void netif_set_gso_max_size(struct net_device *dev, · 99 unmodified lines | ||
| 100 | 100 | { |
| 101 | 101 | /* dev->gso_max_size is read locklessly from sk_setup_caps() */ |
| 102 | 102 | WRITE_ONCE(dev->gso_max_size, size); |
| 103 | + if (size <= GSO_LEGACY_MAX_SIZE) | |
| 104 | + WRITE_ONCE(dev->gso_ipv4_max_size, size); | |
| 103 | 105 | } |
| 104 | 106 | |
| 105 | 107 | static inline void netif_set_gso_max_segs(struct net_device *dev, |
| @@ -114,6 +116,22 @@ static inline void netif_set_gro_max_size(struct net_device *dev, · 8 unmodified lines | ||
| 114 | 116 | { |
| 115 | 117 | /* This pairs with the READ_ONCE() in skb_gro_receive() */ |
| 116 | 118 | WRITE_ONCE(dev->gro_max_size, size); |
| 119 | + if (size <= GRO_LEGACY_MAX_SIZE) | |
| 120 | + WRITE_ONCE(dev->gro_ipv4_max_size, size); | |
| 121 | +} | |
| 122 | + | |
| 123 | +static inline void netif_set_gso_ipv4_max_size(struct net_device *dev, | |
| 124 | + unsigned int size) | |
| 125 | +{ | |
| 126 | + /* dev->gso_ipv4_max_size is read locklessly from sk_setup_caps() */ | |
| 127 | + WRITE_ONCE(dev->gso_ipv4_max_size, size); | |
| 128 | +} | |
| 129 | + | |
| 130 | +static inline void netif_set_gro_ipv4_max_size(struct net_device *dev, | |
| 131 | + unsigned int size) | |
| 132 | +{ | |
| 133 | + /* This pairs with the READ_ONCE() in skb_gro_receive() */ | |
| 134 | + WRITE_ONCE(dev->gro_ipv4_max_size, size); | |
| 117 | 135 | } |
| 118 | 136 | |
| 119 | 137 | #endif |
| @@ -1074,6 +1074,8 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev, · 1073 unmodified lines | ||
| 1074 | 1074 | + nla_total_size(4) /* IFLA_GSO_MAX_SEGS */ |
| 1075 | 1075 | + nla_total_size(4) /* IFLA_GSO_MAX_SIZE */ |
| 1076 | 1076 | + nla_total_size(4) /* IFLA_GRO_MAX_SIZE */ |
| 1077 | + + nla_total_size(4) /* IFLA_GSO_IPV4_MAX_SIZE */ | |
| 1078 | + + nla_total_size(4) /* IFLA_GRO_IPV4_MAX_SIZE */ | |
| 1077 | 1079 | + nla_total_size(4) /* IFLA_TSO_MAX_SIZE */ |
| 1078 | 1080 | + nla_total_size(4) /* IFLA_TSO_MAX_SEGS */ |
| 1079 | 1081 | + nla_total_size(1) /* IFLA_OPERSTATE */ |
| @@ -1807,6 +1809,8 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, · 727 unmodified lines | ||
| 1807 | 1809 | nla_put_u32(skb, IFLA_GSO_MAX_SEGS, dev->gso_max_segs) || |
| 1808 | 1810 | nla_put_u32(skb, IFLA_GSO_MAX_SIZE, dev->gso_max_size) || |
| 1809 | 1811 | nla_put_u32(skb, IFLA_GRO_MAX_SIZE, dev->gro_max_size) || |
| 1812 | + nla_put_u32(skb, IFLA_GSO_IPV4_MAX_SIZE, dev->gso_ipv4_max_size) || | |
| 1813 | + nla_put_u32(skb, IFLA_GRO_IPV4_MAX_SIZE, dev->gro_ipv4_max_size) || | |
| 1810 | 1814 | nla_put_u32(skb, IFLA_TSO_MAX_SIZE, dev->tso_max_size) || |
| 1811 | 1815 | nla_put_u32(skb, IFLA_TSO_MAX_SEGS, dev->tso_max_segs) || |
| 1812 | 1816 | #ifdef CONFIG_RPS |
| @@ -1968,6 +1972,8 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { · 155 unmodified lines | ||
| 1968 | 1972 | [IFLA_TSO_MAX_SIZE] = { .type = NLA_REJECT }, |
| 1969 | 1973 | [IFLA_TSO_MAX_SEGS] = { .type = NLA_REJECT }, |
| 1970 | 1974 | [IFLA_ALLMULTI] = { .type = NLA_REJECT }, |
| 1975 | + [IFLA_GSO_IPV4_MAX_SIZE] = { .type = NLA_U32 }, | |
| 1976 | + [IFLA_GRO_IPV4_MAX_SIZE] = { .type = NLA_U32 }, | |
| 1971 | 1977 | }; |
| 1972 | 1978 | |
| 1973 | 1979 | static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = { |
| @@ -2883,6 +2889,29 @@ static int do_setlink(const struct sk_buff *skb, · 909 unmodified lines | ||
| 2883 | 2889 | } |
| 2884 | 2890 | } |
| 2885 | 2891 | |
| 2892 | + if (tb[IFLA_GSO_IPV4_MAX_SIZE]) { | |
| 2893 | + u32 max_size = nla_get_u32(tb[IFLA_GSO_IPV4_MAX_SIZE]); | |
| 2894 | + | |
| 2895 | + if (max_size > dev->tso_max_size) { | |
| 2896 | + err = -EINVAL; | |
| 2897 | + goto errout; | |
| 2898 | + } | |
| 2899 | + | |
| 2900 | + if (dev->gso_ipv4_max_size ^ max_size) { | |
| 2901 | + netif_set_gso_ipv4_max_size(dev, max_size); | |
| 2902 | + status |= DO_SETLINK_MODIFIED; | |
| 2903 | + } | |
| 2904 | + } | |
| 2905 | + | |
| 2906 | + if (tb[IFLA_GRO_IPV4_MAX_SIZE]) { | |
| 2907 | + u32 gro_max_size = nla_get_u32(tb[IFLA_GRO_IPV4_MAX_SIZE]); | |
| 2908 | + | |
| 2909 | + if (dev->gro_ipv4_max_size ^ gro_max_size) { | |
| 2910 | + netif_set_gro_ipv4_max_size(dev, gro_max_size); | |
| 2911 | + status |= DO_SETLINK_MODIFIED; | |
| 2912 | + } | |
| 2913 | + } | |
| 2914 | + | |
| 2886 | 2915 | if (tb[IFLA_OPERSTATE]) |
| 2887 | 2916 | set_operstate(dev, nla_get_u8(tb[IFLA_OPERSTATE])); |
| 2888 | 2917 | |
| @@ -3325,6 +3354,10 @@ struct net_device *rtnl_create_link(struct net *net, const char *ifname, · 436 unmodified lines | ||
| 3325 | 3354 | netif_set_gso_max_segs(dev, nla_get_u32(tb[IFLA_GSO_MAX_SEGS])); |
| 3326 | 3355 | if (tb[IFLA_GRO_MAX_SIZE]) |
| 3327 | 3356 | netif_set_gro_max_size(dev, nla_get_u32(tb[IFLA_GRO_MAX_SIZE])); |
| 3357 | + if (tb[IFLA_GSO_IPV4_MAX_SIZE]) | |
| 3358 | + netif_set_gso_ipv4_max_size(dev, nla_get_u32(tb[IFLA_GSO_IPV4_MAX_SIZE])); | |
| 3359 | + if (tb[IFLA_GRO_IPV4_MAX_SIZE]) | |
| 3360 | + netif_set_gro_ipv4_max_size(dev, nla_get_u32(tb[IFLA_GRO_IPV4_MAX_SIZE])); | |
| 3328 | 3361 | |
| 3329 | 3362 | return dev; |
| 3330 | 3363 | } |