Skip to content

Commit 546bc0a

Browse files
committed
tgupdate: merge t/DO-NOT-MERGE-mptcp-enabled-by-default into t/upstream base
2 parents 928ebf1 + 1610c58 commit 546bc0a

File tree

12 files changed

+140
-58
lines changed

12 files changed

+140
-58
lines changed

drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2967,7 +2967,7 @@ static inline int i40e_check_vf_permission(struct i40e_vf *vf,
29672967
dev_err(&pf->pdev->dev,
29682968
"Cannot add more MAC addresses: VF reached its maximum allowed limit (%d)\n",
29692969
mac_add_max);
2970-
return -EPERM;
2970+
return -EPERM;
29712971
}
29722972
if (!vf_trusted) {
29732973
dev_err(&pf->pdev->dev,

drivers/net/ethernet/marvell/mvneta.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5012,17 +5012,9 @@ static u32 mvneta_ethtool_get_rxfh_indir_size(struct net_device *dev)
50125012
return MVNETA_RSS_LU_TABLE_SIZE;
50135013
}
50145014

5015-
static int mvneta_ethtool_get_rxnfc(struct net_device *dev,
5016-
struct ethtool_rxnfc *info,
5017-
u32 *rules __always_unused)
5015+
static u32 mvneta_ethtool_get_rx_ring_count(struct net_device *dev)
50185016
{
5019-
switch (info->cmd) {
5020-
case ETHTOOL_GRXRINGS:
5021-
info->data = rxq_number;
5022-
return 0;
5023-
default:
5024-
return -EOPNOTSUPP;
5025-
}
5017+
return rxq_number;
50265018
}
50275019

50285020
static int mvneta_config_rss(struct mvneta_port *pp)
@@ -5356,7 +5348,7 @@ static const struct ethtool_ops mvneta_eth_tool_ops = {
53565348
.get_ethtool_stats = mvneta_ethtool_get_stats,
53575349
.get_sset_count = mvneta_ethtool_get_sset_count,
53585350
.get_rxfh_indir_size = mvneta_ethtool_get_rxfh_indir_size,
5359-
.get_rxnfc = mvneta_ethtool_get_rxnfc,
5351+
.get_rx_ring_count = mvneta_ethtool_get_rx_ring_count,
53605352
.get_rxfh = mvneta_ethtool_get_rxfh,
53615353
.set_rxfh = mvneta_ethtool_set_rxfh,
53625354
.get_link_ksettings = mvneta_ethtool_get_link_ksettings,

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5580,6 +5580,13 @@ static int mvpp2_ethtool_set_link_ksettings(struct net_device *dev,
55805580
return phylink_ethtool_ksettings_set(port->phylink, cmd);
55815581
}
55825582

5583+
static u32 mvpp2_ethtool_get_rx_ring_count(struct net_device *dev)
5584+
{
5585+
struct mvpp2_port *port = netdev_priv(dev);
5586+
5587+
return port->nrxqs;
5588+
}
5589+
55835590
static int mvpp2_ethtool_get_rxnfc(struct net_device *dev,
55845591
struct ethtool_rxnfc *info, u32 *rules)
55855592
{
@@ -5590,9 +5597,6 @@ static int mvpp2_ethtool_get_rxnfc(struct net_device *dev,
55905597
return -EOPNOTSUPP;
55915598

55925599
switch (info->cmd) {
5593-
case ETHTOOL_GRXRINGS:
5594-
info->data = port->nrxqs;
5595-
break;
55965600
case ETHTOOL_GRXCLSRLCNT:
55975601
info->rule_cnt = port->n_rfs_rules;
55985602
break;
@@ -5827,6 +5831,7 @@ static const struct ethtool_ops mvpp2_eth_tool_ops = {
58275831
.set_pauseparam = mvpp2_ethtool_set_pause_param,
58285832
.get_link_ksettings = mvpp2_ethtool_get_link_ksettings,
58295833
.set_link_ksettings = mvpp2_ethtool_set_link_ksettings,
5834+
.get_rx_ring_count = mvpp2_ethtool_get_rx_ring_count,
58305835
.get_rxnfc = mvpp2_ethtool_get_rxnfc,
58315836
.set_rxnfc = mvpp2_ethtool_set_rxnfc,
58325837
.get_rxfh_indir_size = mvpp2_ethtool_get_rxfh_indir_size,

drivers/net/hyperv/netvsc_drv.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,22 +1624,15 @@ netvsc_get_rxfh_fields(struct net_device *ndev,
16241624
return 0;
16251625
}
16261626

1627-
static int
1628-
netvsc_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
1629-
u32 *rules)
1627+
static u32 netvsc_get_rx_ring_count(struct net_device *dev)
16301628
{
16311629
struct net_device_context *ndc = netdev_priv(dev);
16321630
struct netvsc_device *nvdev = rtnl_dereference(ndc->nvdev);
16331631

16341632
if (!nvdev)
1635-
return -ENODEV;
1636-
1637-
switch (info->cmd) {
1638-
case ETHTOOL_GRXRINGS:
1639-
info->data = nvdev->num_chn;
16401633
return 0;
1641-
}
1642-
return -EOPNOTSUPP;
1634+
1635+
return nvdev->num_chn;
16431636
}
16441637

16451638
static int
@@ -1969,7 +1962,7 @@ static const struct ethtool_ops ethtool_ops = {
19691962
.get_channels = netvsc_get_channels,
19701963
.set_channels = netvsc_set_channels,
19711964
.get_ts_info = ethtool_op_get_ts_info,
1972-
.get_rxnfc = netvsc_get_rxnfc,
1965+
.get_rx_ring_count = netvsc_get_rx_ring_count,
19731966
.get_rxfh_key_size = netvsc_get_rxfh_key_size,
19741967
.get_rxfh_indir_size = netvsc_rss_indir_size,
19751968
.get_rxfh = netvsc_get_rxfh,

drivers/net/ipvlan/ipvlan_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ static u8 ipvlan_get_v4_hash(const void *iaddr)
5252
{
5353
const struct in_addr *ip4_addr = iaddr;
5454

55-
return jhash_1word(ip4_addr->s_addr, ipvlan_jhash_secret) &
56-
IPVLAN_HASH_MASK;
55+
return jhash_1word((__force u32)ip4_addr->s_addr, ipvlan_jhash_secret) &
56+
IPVLAN_HASH_MASK;
5757
}
5858

5959
static bool addr_equal(bool is_v6, struct ipvl_addr *addr, const void *iaddr)

net/ethernet/eth.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ EXPORT_SYMBOL(eth_get_headlen);
154154
*/
155155
__be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
156156
{
157-
unsigned short _service_access_point;
158157
const unsigned short *sap;
159158
const struct ethhdr *eth;
159+
__be16 res;
160160

161161
skb->dev = dev;
162162
skb_reset_mac_header(skb);
@@ -181,15 +181,15 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
181181
* the protocol design and runs IPX over 802.3 without an 802.2 LLC
182182
* layer. We look for FFFF which isn't a used 802.2 SSAP/DSAP. This
183183
* won't work for fault tolerant netware but does for the rest.
184+
* We use skb->dev as temporary storage to not hit
185+
* CONFIG_STACKPROTECTOR_STRONG=y costs on some platforms.
184186
*/
185-
sap = skb_header_pointer(skb, 0, sizeof(*sap), &_service_access_point);
186-
if (sap && *sap == 0xFFFF)
187-
return htons(ETH_P_802_3);
187+
sap = skb_header_pointer(skb, 0, sizeof(*sap), &skb->dev);
188+
res = (sap && *sap == 0xFFFF) ? htons(ETH_P_802_3) : htons(ETH_P_802_2);
188189

189-
/*
190-
* Real 802.2 LLC
191-
*/
192-
return htons(ETH_P_802_2);
190+
/* restore skb->dev in case it was mangled by skb_header_pointer(). */
191+
skb->dev = dev;
192+
return res;
193193
}
194194
EXPORT_SYMBOL(eth_type_trans);
195195

net/mptcp/protocol.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2518,6 +2518,13 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
25182518
subflow->lent_mem_frag = 0;
25192519
}
25202520

2521+
/* Do not pass RX data to the msk, even if the subflow socket is not
2522+
* going to be freed (i.e. even for the first subflow on graceful
2523+
* subflow close.
2524+
*/
2525+
lock_sock_nested(ssk, SINGLE_DEPTH_NESTING);
2526+
subflow->closing = 1;
2527+
25212528
/* If the first subflow moved to a close state before accept, e.g. due
25222529
* to an incoming reset or listener shutdown, the subflow socket is
25232530
* already deleted by inet_child_forget() and the mptcp socket can't

tools/testing/selftests/drivers/net/hw/Makefile

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
# SPDX-License-Identifier: GPL-2.0+ OR MIT
22

3+
# Check if io_uring supports zero-copy receive
4+
HAS_IOURING_ZCRX := $(shell \
5+
echo -e '#include <liburing.h>\n' \
6+
'void *func = (void *)io_uring_register_ifq;\n' \
7+
'int main() {return 0;}' | \
8+
$(CC) -luring -x c - -o /dev/null 2>&1 && echo y)
9+
10+
ifeq ($(HAS_IOURING_ZCRX),y)
11+
COND_GEN_FILES += iou-zcrx
12+
else
13+
$(warning excluding iouring tests, liburing not installed or too old)
14+
endif
15+
316
TEST_GEN_FILES := \
4-
iou-zcrx \
5-
toeplitz \
17+
$(COND_GEN_FILES) \
618
# end of TEST_GEN_FILES
719

820
TEST_PROGS = \
@@ -42,7 +54,10 @@ TEST_INCLUDES := \
4254
#
4355

4456
# YNL files, must be before "include ..lib.mk"
45-
YNL_GEN_FILES := ncdevmem
57+
YNL_GEN_FILES := \
58+
ncdevmem \
59+
toeplitz \
60+
# end of YNL_GEN_FILES
4661
TEST_GEN_FILES += $(YNL_GEN_FILES)
4762
TEST_GEN_FILES += $(patsubst %.c,%.o,$(wildcard *.bpf.c))
4863

@@ -58,4 +73,6 @@ include ../../../net/ynl.mk
5873

5974
include ../../../net/bpf.mk
6075

76+
ifeq ($(HAS_IOURING_ZCRX),y)
6177
$(OUTPUT)/iou-zcrx: LDLIBS += -luring
78+
endif

tools/testing/selftests/drivers/net/hw/toeplitz.c

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
#include <sys/types.h>
5353
#include <unistd.h>
5454

55+
#include <ynl.h>
56+
#include "ethtool-user.h"
57+
5558
#include "../../../kselftest.h"
5659
#include "../../../net/lib/ksft.h"
5760

@@ -65,6 +68,7 @@
6568
#define FOUR_TUPLE_MAX_LEN ((sizeof(struct in6_addr) * 2) + (sizeof(uint16_t) * 2))
6669

6770
#define RSS_MAX_CPUS (1 << 16) /* real constraint is PACKET_FANOUT_MAX */
71+
#define RSS_MAX_INDIR (1 << 16)
6872

6973
#define RPS_MAX_CPUS 16UL /* must be a power of 2 */
7074

@@ -102,6 +106,8 @@ struct ring_state {
102106
static unsigned int rx_irq_cpus[RSS_MAX_CPUS]; /* map from rxq to cpu */
103107
static int rps_silo_to_cpu[RPS_MAX_CPUS];
104108
static unsigned char toeplitz_key[TOEPLITZ_KEY_MAX_LEN];
109+
static unsigned int rss_indir_tbl[RSS_MAX_INDIR];
110+
static unsigned int rss_indir_tbl_size;
105111
static struct ring_state rings[RSS_MAX_CPUS];
106112

107113
static inline uint32_t toeplitz(const unsigned char *four_tuple,
@@ -130,7 +136,12 @@ static inline uint32_t toeplitz(const unsigned char *four_tuple,
130136
/* Compare computed cpu with arrival cpu from packet_fanout_cpu */
131137
static void verify_rss(uint32_t rx_hash, int cpu)
132138
{
133-
int queue = rx_hash % cfg_num_queues;
139+
int queue;
140+
141+
if (rss_indir_tbl_size)
142+
queue = rss_indir_tbl[rx_hash % rss_indir_tbl_size];
143+
else
144+
queue = rx_hash % cfg_num_queues;
134145

135146
log_verbose(" rxq %d (cpu %d)", queue, rx_irq_cpus[queue]);
136147
if (rx_irq_cpus[queue] != cpu) {
@@ -483,6 +494,56 @@ static void parse_rps_bitmap(const char *arg)
483494
rps_silo_to_cpu[cfg_num_rps_cpus++] = i;
484495
}
485496

497+
static void read_rss_dev_info_ynl(void)
498+
{
499+
struct ethtool_rss_get_req *req;
500+
struct ethtool_rss_get_rsp *rsp;
501+
struct ynl_sock *ys;
502+
503+
ys = ynl_sock_create(&ynl_ethtool_family, NULL);
504+
if (!ys)
505+
error(1, errno, "ynl_sock_create failed");
506+
507+
req = ethtool_rss_get_req_alloc();
508+
if (!req)
509+
error(1, errno, "ethtool_rss_get_req_alloc failed");
510+
511+
ethtool_rss_get_req_set_header_dev_name(req, cfg_ifname);
512+
513+
rsp = ethtool_rss_get(ys, req);
514+
if (!rsp)
515+
error(1, ys->err.code, "YNL: %s", ys->err.msg);
516+
517+
if (!rsp->_len.hkey)
518+
error(1, 0, "RSS key not available for %s", cfg_ifname);
519+
520+
if (rsp->_len.hkey < TOEPLITZ_KEY_MIN_LEN ||
521+
rsp->_len.hkey > TOEPLITZ_KEY_MAX_LEN)
522+
error(1, 0, "RSS key length %u out of bounds [%u, %u]",
523+
rsp->_len.hkey, TOEPLITZ_KEY_MIN_LEN,
524+
TOEPLITZ_KEY_MAX_LEN);
525+
526+
memcpy(toeplitz_key, rsp->hkey, rsp->_len.hkey);
527+
528+
if (rsp->_count.indir > RSS_MAX_INDIR)
529+
error(1, 0, "RSS indirection table too large (%u > %u)",
530+
rsp->_count.indir, RSS_MAX_INDIR);
531+
532+
/* If indir table not available we'll fallback to simple modulo math */
533+
if (rsp->_count.indir) {
534+
memcpy(rss_indir_tbl, rsp->indir,
535+
rsp->_count.indir * sizeof(rss_indir_tbl[0]));
536+
rss_indir_tbl_size = rsp->_count.indir;
537+
538+
log_verbose("RSS indirection table size: %u\n",
539+
rss_indir_tbl_size);
540+
}
541+
542+
ethtool_rss_get_rsp_free(rsp);
543+
ethtool_rss_get_req_free(req);
544+
ynl_sock_destroy(ys);
545+
}
546+
486547
static void parse_opts(int argc, char **argv)
487548
{
488549
static struct option long_options[] = {
@@ -551,7 +612,7 @@ static void parse_opts(int argc, char **argv)
551612
}
552613

553614
if (!have_toeplitz)
554-
error(1, 0, "Must supply rss key ('-k')");
615+
read_rss_dev_info_ynl();
555616

556617
num_cpus = get_nprocs();
557618
if (num_cpus > RSS_MAX_CPUS)

tools/testing/selftests/drivers/net/hw/toeplitz.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
from lib.py import ksft_in
1818
from lib.py import ksft_variants, KsftNamedVariant, KsftSkipEx, KsftFailEx
1919

20+
# "define" for the ID of the Toeplitz hash function
21+
ETH_RSS_HASH_TOP = 1
22+
2023

2124
def _check_rps_and_rfs_not_configured(cfg):
2225
"""Verify that RPS is not already configured."""
@@ -34,16 +37,6 @@ def _check_rps_and_rfs_not_configured(cfg):
3437
raise KsftSkipEx(f"RFS already configured {rfs_file}: {val}")
3538

3639

37-
def _get_rss_key(cfg):
38-
"""
39-
Read the RSS key from the device.
40-
Return a string in the traditional %02x:%02x:%02x:.. format.
41-
"""
42-
43-
rss = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}})
44-
return ':'.join(f'{b:02x}' for b in rss["hkey"])
45-
46-
4740
def _get_cpu_for_irq(irq):
4841
with open(f"/proc/irq/{irq}/smp_affinity_list", "r",
4942
encoding="utf-8") as fp:
@@ -153,8 +146,18 @@ def test(cfg, proto_flag, ipver, grp):
153146
# Check that rxhash is enabled
154147
ksft_in("receive-hashing: on", cmd(f"ethtool -k {cfg.ifname}").stdout)
155148

149+
rss = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}})
150+
# Make sure NIC is configured to use Toeplitz hash, and no key xfrm.
151+
if rss.get('hfunc') != ETH_RSS_HASH_TOP or rss.get('input-xfrm'):
152+
cfg.ethnl.rss_set({"header": {"dev-index": cfg.ifindex},
153+
"hfunc": ETH_RSS_HASH_TOP,
154+
"input-xfrm": {}})
155+
defer(cfg.ethnl.rss_set, {"header": {"dev-index": cfg.ifindex},
156+
"hfunc": rss.get('hfunc'),
157+
"input-xfrm": rss.get('input-xfrm', {})
158+
})
159+
156160
port = rand_port(socket.SOCK_DGRAM)
157-
key = _get_rss_key(cfg)
158161

159162
toeplitz_path = cfg.test_dir / "toeplitz"
160163
rx_cmd = [
@@ -163,8 +166,7 @@ def test(cfg, proto_flag, ipver, grp):
163166
proto_flag,
164167
"-d", str(port),
165168
"-i", cfg.ifname,
166-
"-k", key,
167-
"-T", "1000",
169+
"-T", "4000",
168170
"-s",
169171
"-v"
170172
]

0 commit comments

Comments
 (0)