| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/10/08 01:20 | flow | patch-triage |
8mArgs:null Results: {
"EnableConfigs": [
"NET_VENDOR_QUALCOMM",
"RMNET"
],
"FocusSymbols": [
"rmnet_map_process_next_hdr_packet",
"rmnet_map_segment_coal_skb",
"__rmnet_map_segment_coal_skb",
"rmnet_map_coal_validate_bounds",
"rmnet_map_data_check_coal_header",
"rmnet_map_coal_gro_fast_path",
"rmnet_vnd_update_dev_mtu",
"rmnet_newlink"
],
"KMSANReasoning": "The patch series implements MAPv5 packet coalescing support and per-CPU diagnostic statistics for the Qualcomm rmnet driver.\n\nKASAN vs KMSAN applicability:\n- Potential risks introduced by these changes center around incoming packet parsing: decoding Number-Length Object (NLO) headers, calculating packet boundaries, reconstructing logical segments from coalesced frames, and manipulating SKB headroom/tailroom. Any bugs in these areas (such as buffer over-reads or out-of-bounds pointer arithmetic on malformed network packets) are out-of-bounds accesses detected by KASAN.\n- KMSAN is not justified here because there are no uninitialized memory risks:\n 1. All new or modified stack variables (e.g., `struct rmnet_map_coal_metadata coal_meta`, `struct rmnet_priv_stats total_stats`) are explicitly zero-initialized via `memset()` or `{ }`.\n 2. Out-parameters in helper functions (e.g., `rmnet_map_data_check_coal_header`) are unconditionally populated on success and callers abort on error before consuming them.\n 3. Statistics reported to userspace or netlink/ethtool (`rmnet_get_ethtool_stats`, `rmnet_get_stats64`, and `rmnet_get_queue_stats_rx`) are aggregated into zero-initialized structures; the ethtool buffer length matches the field count without padding gaps.\n 4. Per-CPU statistics structures are allocated with `alloc_percpu()` (which zeroes memory).\n 5. Segment SKBs allocated via `alloc_skb()` are completely filled with payload and restored headers via `skb_put_data()`, `skb_push()`, and `memcpy()`, leaving no uninitialized data bytes.\n\nBecause the risks are bounded to buffer boundaries and logic validation (monitored by KASAN) and no uninitialized memory or info-leak vectors are introduced, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false,
"Reasoning": "The patch adds MAPv5 downlink packet coalescing and de-aggregation support to Qualcomm's rmnet driver. RMNet is an rtnl virtual netlink device (kind \"rmnet\") that can attach to any underlying network interface (including virtual devices such as dummy or veth) without dedicated physical hardware. Ingress packets can be delivered from userspace through the base interface to exercise the new frame parsing, NLO validation, checksum verification, skb reallocation, and GSO segment construction logic. This complex network packet manipulation is fully reachable in virtualized fuzzing environments.",
"WorthFuzzing": true
} |
| 1/1 | 2026/10/08 01:20 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 5f934836a3da604812716de3e50f9bc46f6de000\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Thu Oct 8 01:20:03 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/Documentation/networking/device_drivers/cellular/qualcomm/rmnet.rst b/Documentation/networking/device_drivers/cellular/qualcomm/rmnet.rst\nindex 5aedbabb73827..52f92d2fba311 100644\n--- a/Documentation/networking/device_drivers/cellular/qualcomm/rmnet.rst\n+++ b/Documentation/networking/device_drivers/cellular/qualcomm/rmnet.rst\n@@ -125,8 +125,8 @@ Command (1)/ Data (0) bit value is to indicate if the packet is a MAP command\n or data packet. Command packet is used for transport level flow control. Data\n packets are standard IP packets.\n \n-Next header is used to indicate the presence of another header, currently is\n-limited to checksum header.\n+Next header is used to indicate the presence of another header, currently\n+limited to the checksum and coalescing headers.\n \n Padding is the number of bytes to be appended to the payload to\n ensure 4 byte alignment.\n@@ -150,11 +150,11 @@ Header Type is to indicate the type of header, this usually is set to CHECKSUM\n \n Header types\n \n-= ===============\n+= ======================\n 0 Reserved\n-1 Reserved\n+1 coalescing header\n 2 checksum header\n-= ===============\n+= ======================\n \n Checksum Valid is to indicate whether the header checksum is valid. Value of 1\n implies that checksum is calculated on this packet and is valid, value of 0\n@@ -162,8 +162,109 @@ indicates that the calculated packet checksum is invalid.\n \n Reserved bits must be zero when sent and ignored when received.\n \n-e. MAP packet v1/v5 (command specific)\n---------------------------------------\n+e. Coalescing header v5\n+------------------------\n+\n+Hardware can coalesce multiple same-flow IP packets into a single MAP frame\n+to reduce per-packet overhead at high data rates. Packets are grouped into\n+NLOs, with all packets in each NLO having the same length. The coalescing\n+header (header type 1) describes the coalesced content.\n+\n+Packet format::\n+\n+ Bit 0 - 6 7 8 9-11 12-15\n+ Function Header Type Next Header CSUM valid Num NLOs (reserved)\n+\n+ Bit 16-19 20-23\n+ Function Close value Close type\n+\n+ Bit 24-27 28-31\n+ Function (reserved) VEID\n+\n+ Bit 32 - 47 48 - 55 56 - 63\n+ Function Packet length CSUM error bitmap Num packets (NLO 0)\n+\n+ ... (up to 6 NLO entries total, same 32-bit format per entry)\n+\n+Header Type is set to 1 (coalescing).\n+\n+The MAP header ``pkt_len`` includes the coalescing header, coalesced packet\n+data, and any MAP padding.\n+\n+Num NLOs (Number-Length Objects) is the count of active NLO entries\n+(1 – 6). Each NLO describes a group of consecutive coalesced packets\n+that all share the same IP packet length.\n+\n+Num NLOs identifies the active prefix of the six NLO slots. The header\n+always contains all six slots and remains 28 bytes long regardless of Num\n+NLOs. A slot with ``num_packets == 0`` ends the active NLO prefix. The\n+full coalescing header is included in the MAP header's ``pkt_len``.\n+\n+Some hardware may report Num NLOs incorrectly. For compatibility, receivers\n+should derive the active prefix from ``num_packets`` when needed. This\n+requires unused slots to have ``num_packets == 0``.\n+\n+CSUM valid (bit 8) is a frame-level indication that the hardware checksum is\n+valid for all packets in the frame. It is distinct from the per-packet CSUM\n+error bitmap in each NLO entry.\n+\n+For a single-NLO, single-packet frame, CSUM valid must not be trusted when\n+the close reason is a FIN/PSH close, a packet limit, a byte limit, or a time\n+limit. In these cases, the rmnet driver treats the packet checksum as\n+unverified and lets the network stack validate it instead of relying on the\n+coalescing checksum indications.\n+IPv4 UDP packets with a zero checksum remain valid because that checksum is\n+optional.\n+\n+Close type and close value encode the hardware reason that coalescing\n+was terminated for this frame:\n+\n+Close type values:\n+\n+= ==============================\n+0 non-coalesced (single packet)\n+1 IP flow miss\n+2 transport flow miss\n+3 hardware limit (see value)\n+4 coalescing closed (FIN/PSH)\n+= ==============================\n+\n+Close value (used when close type is 3):\n+\n+= ==================\n+0 NL limit reached\n+1 packet limit\n+2 byte limit\n+3 time limit\n+4 eviction\n+= ==================\n+\n+VEID is the virtual endpoint ID of the originating flow.\n+\n+Each NLO entry::\n+\n+ Bit 0 - 15 16 - 23 24 - 31\n+ Function Pkt length CSUM error bitmap Num packets\n+\n+Pkt length is the full IP packet length, including the IP header, transport\n+header, and payload, for every packet in this NLO group. The IP and transport\n+headers are present once in the coalesced frame and are not repeated for each\n+packet.\n+\n+CSUM error bitmap is one 48-bit stream formed by concatenating the\n+``csum_error_bitmap`` bytes from all six NLO slots in slot order. Packet 0\n+corresponds to bit 0 of slot 0's bitmap byte, and bits are consumed from\n+least significant bit to most significant bit. The bit stream is indexed by\n+the packet's absolute position in the frame and does not restart at an NLO\n+boundary. If an NLO contains more than eight packets, its error bits\n+continue into the bitmap byte of the following slot. Bitmap bytes in slots\n+after the active NLO prefix may therefore contain continuation bits and must\n+not be ignored.\n+\n+Num packets is the count of coalesced packets described by this NLO.\n+\n+f. MAP packet v1/v5 (command specific)\n+---------------------------------------\n \n Packet format::\n \n@@ -187,7 +288,7 @@ Command types\n 3 is for error during processing of commands\n = ==========================================\n \n-f. Aggregation\n+g. Aggregation\n --------------\n \n Aggregation is multiple MAP packets (can be data or command) delivered to\n@@ -208,3 +309,39 @@ rmnet userspace configuration is done through netlink using iproute2\n https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/\n \n The driver uses rtnl_link_ops for communication.\n+\n+The data format flags controlling the ingress and egress processing\n+pipeline are set via the ``IFLA_RMNET_FLAGS`` attribute\n+(``struct ifla_rmnet_flags``).\n+\n+Relevant ingress flags:\n+\n+``RMNET_FLAGS_INGRESS_DEAGGREGATION``\n+ Enable MAP frame de-aggregation.\n+\n+``RMNET_FLAGS_INGRESS_MAP_CKSUMV4``\n+ Enable MAPv4 downlink checksum offload.\n+\n+``RMNET_FLAGS_INGRESS_MAP_CKSUMV5``\n+ Enable MAPv5 downlink checksum offload (header type 2).\n+\n+``RMNET_FLAGS_INGRESS_COALESCE``\n+ Enable MAPv5 downlink hardware coalescing (header type 1).\n+ This flag requires ``RMNET_FLAGS_INGRESS_MAP_CKSUMV5``. MAPv4 and\n+ MAPv5 checksum flags cannot be enabled together in either direction.\n+ A direction may leave checksum offload disabled. Invalid combinations\n+ are rejected.\n+ When RX checksum offload and ``rx-gro-hw`` are enabled, valid\n+ multi-packet coalesced frames can be delivered as batched GSO SKBs.\n+ Otherwise, multi-packet coalesced frames are rejected. A coalesced frame\n+ containing one packet is delivered as a normal non-GSO skb. IP options,\n+ IPv6 extension headers, and zero-payload packets can also prevent GSO\n+ processing for a frame.\n+\n+Relevant egress flags:\n+\n+``RMNET_FLAGS_EGRESS_MAP_CKSUMV4``\n+ Enable MAPv4 uplink checksum offload.\n+\n+``RMNET_FLAGS_EGRESS_MAP_CKSUMV5``\n+ Enable MAPv5 uplink checksum offload.\ndiff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c\nindex 61b04c6c0390e..ec882ad371ab7 100644\n--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c\n+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c\n@@ -26,6 +26,31 @@ static int rmnet_is_real_dev_registered(const struct net_device *real_dev)\n \treturn rcu_access_pointer(real_dev-\u003erx_handler) == rmnet_rx_handler;\n }\n \n+/* Only three MAP configurations are supported: MAPv1 (no checksum\n+ * offload), MAPv4 (v4 checksum offload) and MAPv5 (v5 checksum\n+ * offload). MAP command support is orthogonal and permitted with any\n+ * of the three. Checksum offload versions are selected independently\n+ * for ingress and egress, but only one version may be enabled across\n+ * the device. Mixing v4 and v5 checksum flags is not supported. DL\n+ * packet coalescing additionally requires a MAPv5 configuration.\n+ */\n+static bool rmnet_config_data_format_valid(u32 data_format)\n+{\n+\tu32 v4_mask = RMNET_FLAGS_INGRESS_MAP_CKSUMV4 |\n+\t\t RMNET_FLAGS_EGRESS_MAP_CKSUMV4;\n+\tu32 v5_mask = RMNET_FLAGS_INGRESS_MAP_CKSUMV5 |\n+\t\t RMNET_FLAGS_EGRESS_MAP_CKSUMV5;\n+\n+\tif ((data_format \u0026 v4_mask) \u0026\u0026 (data_format \u0026 v5_mask))\n+\t\treturn false;\n+\n+\tif ((data_format \u0026 RMNET_FLAGS_INGRESS_COALESCE) \u0026\u0026\n+\t !(data_format \u0026 RMNET_FLAGS_INGRESS_MAP_CKSUMV5))\n+\t\treturn false;\n+\n+\treturn true;\n+}\n+\n /* Needs rtnl lock */\n struct rmnet_port*\n rmnet_get_port_rtnl(const struct net_device *real_dev)\n@@ -143,6 +168,20 @@ static int rmnet_newlink(struct net_device *dev,\n \t\treturn -ENODEV;\n \t}\n \n+\tif (data[IFLA_RMNET_FLAGS]) {\n+\t\tstruct ifla_rmnet_flags *flags;\n+\n+\t\tflags = nla_data(data[IFLA_RMNET_FLAGS]);\n+\t\tdata_format \u0026= ~flags-\u003emask;\n+\t\tdata_format |= flags-\u003eflags \u0026 flags-\u003emask;\n+\t}\n+\n+\tif (!rmnet_config_data_format_valid(data_format)) {\n+\t\tNL_SET_ERR_MSG_MOD(extack,\n+\t\t\t\t \"unsupported MAP checksum flag combination\");\n+\t\treturn -EINVAL;\n+\t}\n+\n \tep = kzalloc_obj(*ep);\n \tif (!ep)\n \t\treturn -ENOMEM;\n@@ -154,7 +193,8 @@ static int rmnet_newlink(struct net_device *dev,\n \t\tgoto err0;\n \n \tport = rmnet_get_port_rtnl(real_dev);\n-\terr = rmnet_vnd_newlink(mux_id, dev, port, real_dev, ep, extack);\n+\terr = rmnet_vnd_newlink(mux_id, dev, port, real_dev, ep, extack,\n+\t\t\t\tdata_format);\n \tif (err)\n \t\tgoto err1;\n \n@@ -162,24 +202,23 @@ static int rmnet_newlink(struct net_device *dev,\n \tif (err \u003c 0)\n \t\tgoto err2;\n \n+\t/* Update existing MTUs before publishing the shared data format. */\n+\terr = rmnet_vnd_update_dev_mtu(port, real_dev, data_format);\n+\tif (err)\n+\t\tgoto err3;\n+\n \tport-\u003ermnet_mode = mode;\n \tport-\u003ermnet_dev = dev;\n \n \thlist_add_head_rcu(\u0026ep-\u003ehlnode, \u0026port-\u003emuxed_ep[mux_id]);\n \n-\tif (data[IFLA_RMNET_FLAGS]) {\n-\t\tstruct ifla_rmnet_flags *flags;\n-\n-\t\tflags = nla_data(data[IFLA_RMNET_FLAGS]);\n-\t\tdata_format \u0026= ~flags-\u003emask;\n-\t\tdata_format |= flags-\u003eflags \u0026 flags-\u003emask;\n-\t}\n-\n \tnetdev_dbg(dev, \"data format [0x%08X]\\n\", data_format);\n \tWRITE_ONCE(port-\u003edata_format, data_format);\n \n \treturn 0;\n \n+err3:\n+\tnetdev_upper_dev_unlink(real_dev, dev);\n err2:\n \tunregister_netdevice(dev);\n \trmnet_vnd_dellink(mux_id, port, ep);\n@@ -301,9 +340,13 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],\n \t\t\t struct netlink_ext_ack *extack)\n {\n \tstruct rmnet_priv *priv = netdev_priv(dev);\n+\tstruct ifla_rmnet_flags *flags;\n \tstruct net_device *real_dev;\n \tstruct rmnet_port *port;\n+\tu32 old_data_format;\n+\tu32 data_format;\n \tu16 mux_id;\n+\tint err;\n \n \tif (!dev)\n \t\treturn -ENODEV;\n@@ -320,6 +363,19 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],\n \n \tport = rmnet_get_port_rtnl(real_dev);\n \n+\tif (data[IFLA_RMNET_FLAGS]) {\n+\t\told_data_format = READ_ONCE(port-\u003edata_format);\n+\t\tflags = nla_data(data[IFLA_RMNET_FLAGS]);\n+\t\tdata_format = old_data_format \u0026 ~flags-\u003emask;\n+\t\tdata_format |= flags-\u003eflags \u0026 flags-\u003emask;\n+\n+\t\tif (!rmnet_config_data_format_valid(data_format)) {\n+\t\t\tNL_SET_ERR_MSG_MOD(extack,\n+\t\t\t\t\t \"unsupported MAP checksum flag combination\");\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\n+\n \tif (data[IFLA_RMNET_MUX_ID]) {\n \t\tmux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]);\n \n@@ -346,21 +402,13 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],\n \t}\n \n \tif (data[IFLA_RMNET_FLAGS]) {\n-\t\tstruct ifla_rmnet_flags *flags;\n-\t\tu32 old_data_format;\n-\t\tu32 data_format;\n-\n-\t\told_data_format = port-\u003edata_format;\n-\t\tflags = nla_data(data[IFLA_RMNET_FLAGS]);\n-\t\tdata_format = old_data_format \u0026 ~flags-\u003emask;\n-\t\tdata_format |= flags-\u003eflags \u0026 flags-\u003emask;\n-\t\tWRITE_ONCE(port-\u003edata_format, data_format);\n-\n-\t\tif (rmnet_vnd_update_dev_mtu(port, real_dev)) {\n-\t\t\tWRITE_ONCE(port-\u003edata_format, old_data_format);\n+\t\terr = rmnet_vnd_update_dev_mtu(port, real_dev, data_format);\n+\t\tif (err) {\n \t\t\tNL_SET_ERR_MSG_MOD(extack, \"Invalid MTU on real dev\");\n-\t\t\treturn -EINVAL;\n+\t\t\treturn err;\n \t\t}\n+\n+\t\tWRITE_ONCE(port-\u003edata_format, data_format);\n \t}\n \n \treturn 0;\ndiff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h\nindex 5adda0323dda7..c71587c843e47 100644\n--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h\n+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h\n@@ -63,12 +63,14 @@ struct rmnet_vnd_stats {\n \tu32 tx_drops;\n };\n \n-struct rmnet_pcpu_stats {\n-\tstruct rmnet_vnd_stats stats;\n-\tstruct u64_stats_sync syncp;\n-};\n-\n struct rmnet_priv_stats {\n+\t/* Network stack RX statistics for all rmnet receive paths */\n+\tu64 rx_hw_gro_packets;\n+\tu64 rx_hw_gro_wire_packets;\n+\tu64 rx_alloc_fail;\n+\tu64 rx_dropped;\n+\n+\t/* Custom diagnostics for the coalescing receive path */\n \tu64 csum_ok;\n \tu64 csum_ip4_header_bad;\n \tu64 csum_valid_unset;\n@@ -80,6 +82,77 @@ struct rmnet_priv_stats {\n \tu64 csum_skipped;\n \tu64 csum_sw;\n \tu64 csum_hw;\n+\t/* Coalescing-only counters. Some are subsets of the standard counters. */\n+\tu64 coal_alloc_fail;\n+\tu64 coal_rx;\n+\tu64 coal_pkts;\n+\tu64 coal_hdr_err;\n+\tu64 coal_hdr_pkt_err;\n+\tu64 coal_bounds_err;\n+\tu64 coal_csum_err;\n+\tu64 coal_csum_drop;\n+\tu64 coal_reconstruct;\n+\tu64 coal_ip_invalid;\n+\tu64 coal_trans_invalid;\n+\t/* close-reason sub-counters */\n+\tu64 coal_close_non_coal;\n+\tu64 coal_close_ip_miss;\n+\tu64 coal_close_trans_miss;\n+\tu64 coal_close_hw_nl;\n+\tu64 coal_close_hw_pkt;\n+\tu64 coal_close_hw_byte;\n+\tu64 coal_close_hw_time;\n+\tu64 coal_close_hw_evict;\n+\tu64 coal_close_coal;\n+};\n+\n+struct rmnet_pcpu_priv_stats {\n+\t/* Network stack RX statistics for all rmnet receive paths */\n+\tu64_stats_t rx_hw_gro_packets;\n+\tu64_stats_t rx_hw_gro_wire_packets;\n+\tu64_stats_t rx_alloc_fail;\n+\tu64_stats_t rx_dropped;\n+\n+\t/* Custom diagnostics for the coalescing receive path */\n+\tu64_stats_t csum_ok;\n+\tu64_stats_t csum_ip4_header_bad;\n+\tu64_stats_t csum_valid_unset;\n+\tu64_stats_t csum_validation_failed;\n+\tu64_stats_t csum_err_bad_buffer;\n+\tu64_stats_t csum_err_invalid_ip_version;\n+\tu64_stats_t csum_err_invalid_transport;\n+\tu64_stats_t csum_fragmented_pkt;\n+\tu64_stats_t csum_skipped;\n+\tu64_stats_t csum_sw;\n+\tu64_stats_t csum_hw;\n+\t/* Coalescing-only counters. Some are subsets of the standard counters. */\n+\tu64_stats_t coal_alloc_fail;\n+\tu64_stats_t coal_rx;\n+\tu64_stats_t coal_pkts;\n+\tu64_stats_t coal_hdr_err;\n+\tu64_stats_t coal_hdr_pkt_err;\n+\tu64_stats_t coal_bounds_err;\n+\tu64_stats_t coal_csum_err;\n+\tu64_stats_t coal_csum_drop;\n+\tu64_stats_t coal_reconstruct;\n+\tu64_stats_t coal_ip_invalid;\n+\tu64_stats_t coal_trans_invalid;\n+\t/* close-reason sub-counters */\n+\tu64_stats_t coal_close_non_coal;\n+\tu64_stats_t coal_close_ip_miss;\n+\tu64_stats_t coal_close_trans_miss;\n+\tu64_stats_t coal_close_hw_nl;\n+\tu64_stats_t coal_close_hw_pkt;\n+\tu64_stats_t coal_close_hw_byte;\n+\tu64_stats_t coal_close_hw_time;\n+\tu64_stats_t coal_close_hw_evict;\n+\tu64_stats_t coal_close_coal;\n+};\n+\n+struct rmnet_pcpu_stats {\n+\tstruct rmnet_vnd_stats stats;\n+\tstruct rmnet_pcpu_priv_stats priv_stats;\n+\tstruct u64_stats_sync syncp;\n };\n \n struct rmnet_priv {\n@@ -87,7 +160,6 @@ struct rmnet_priv {\n \tstruct net_device *real_dev;\n \tstruct rmnet_pcpu_stats __percpu *pcpu_stats;\n \tstruct gro_cells gro_cells;\n-\tstruct rmnet_priv_stats stats;\n };\n \n struct rmnet_port *rmnet_get_port_rcu(const struct net_device *real_dev);\ndiff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c\nindex aa5523f4618eb..bb867ceb01c1c 100644\n--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c\n+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c\n@@ -50,6 +50,16 @@ rmnet_deliver_skb(struct sk_buff *skb)\n \tgro_cells_receive(\u0026priv-\u003egro_cells, skb);\n }\n \n+static void rmnet_deliver_skb_list(struct sk_buff_head *head)\n+{\n+\tstruct sk_buff *skb;\n+\n+\twhile ((skb = __skb_dequeue(head))) {\n+\t\trmnet_set_skb_proto(skb);\n+\t\trmnet_deliver_skb(skb);\n+\t}\n+}\n+\n /* MAP handler */\n \n static void\n@@ -59,6 +69,7 @@ __rmnet_map_ingress_handler(struct sk_buff *skb,\n {\n \tstruct rmnet_map_header *map_header = (void *)skb-\u003edata;\n \tstruct rmnet_endpoint *ep;\n+\tstruct sk_buff_head list;\n \tu16 len, pad;\n \tu8 mux_id;\n \n@@ -83,12 +94,13 @@ __rmnet_map_ingress_handler(struct sk_buff *skb,\n \n \tskb-\u003edev = ep-\u003eegress_dev;\n \n-\tif ((data_format \u0026 RMNET_FLAGS_INGRESS_MAP_CKSUMV5) \u0026\u0026\n+\t__skb_queue_head_init(\u0026list);\n+\n+\tif ((data_format \u0026\n+\t (RMNET_FLAGS_INGRESS_MAP_CKSUMV5 | RMNET_FLAGS_INGRESS_COALESCE)) \u0026\u0026\n \t (map_header-\u003eflags \u0026 MAP_NEXT_HEADER_FLAG)) {\n-\t\tif (rmnet_map_process_next_hdr_packet(skb, len))\n+\t\tif (rmnet_map_process_next_hdr_packet(skb, \u0026list, len, data_format))\n \t\t\tgoto free_skb;\n-\t\tskb_pull(skb, sizeof(*map_header));\n-\t\trmnet_set_skb_proto(skb);\n \t} else {\n \t\t/* Subtract MAP header */\n \t\tskb_pull(skb, sizeof(*map_header));\n@@ -96,10 +108,11 @@ __rmnet_map_ingress_handler(struct sk_buff *skb,\n \t\tif (data_format \u0026 RMNET_FLAGS_INGRESS_MAP_CKSUMV4 \u0026\u0026\n \t\t !rmnet_map_checksum_downlink_packet(skb, len + pad))\n \t\t\tskb-\u003eip_summed = CHECKSUM_UNNECESSARY;\n+\t\tskb_trim(skb, len);\n+\t\t__skb_queue_tail(\u0026list, skb);\n \t}\n \n-\tskb_trim(skb, len);\n-\trmnet_deliver_skb(skb);\n+\trmnet_deliver_skb_list(\u0026list);\n \treturn;\n \n free_skb:\ndiff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h\nindex 0977e495f5915..77ddac6023c01 100644\n--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h\n+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h\n@@ -6,6 +6,22 @@\n #define _RMNET_MAP_H_\n #include \u003clinux/if_rmnet.h\u003e\n \n+enum rmnet_map_v5_close_type {\n+\tRMNET_MAP_COAL_CLOSE_NON_COAL,\n+\tRMNET_MAP_COAL_CLOSE_IP_MISS,\n+\tRMNET_MAP_COAL_CLOSE_TRANS_MISS,\n+\tRMNET_MAP_COAL_CLOSE_HW,\n+\tRMNET_MAP_COAL_CLOSE_COAL,\n+};\n+\n+enum rmnet_map_v5_close_value {\n+\tRMNET_MAP_COAL_CLOSE_HW_NL,\n+\tRMNET_MAP_COAL_CLOSE_HW_PKT,\n+\tRMNET_MAP_COAL_CLOSE_HW_BYTE,\n+\tRMNET_MAP_COAL_CLOSE_HW_TIME,\n+\tRMNET_MAP_COAL_CLOSE_HW_EVICT,\n+};\n+\n struct rmnet_map_control_command {\n \tu8 command_name;\n \tu8 cmd_type:2;\n@@ -53,7 +69,9 @@ void rmnet_map_checksum_uplink_packet(struct sk_buff *skb,\n \t\t\t\t struct rmnet_port *port,\n \t\t\t\t struct net_device *orig_dev,\n \t\t\t\t int csum_type);\n-int rmnet_map_process_next_hdr_packet(struct sk_buff *skb, u16 len);\n+int rmnet_map_process_next_hdr_packet(struct sk_buff *skb,\n+\t\t\t\t struct sk_buff_head *list,\n+\t\t\t\t u16 len, u32 data_format);\n unsigned int rmnet_map_tx_aggregate(struct sk_buff *skb, struct rmnet_port *port,\n \t\t\t\t struct net_device *orig_dev);\n void rmnet_map_tx_aggregate_init(struct rmnet_port *port);\ndiff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c\nindex 39d6d084e73f0..74d64b7066e2b 100644\n--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c\n+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c\n@@ -7,7 +7,11 @@\n #include \u003clinux/netdevice.h\u003e\n #include \u003clinux/ip.h\u003e\n #include \u003clinux/ipv6.h\u003e\n+#include \u003clinux/tcp.h\u003e\n+#include \u003clinux/udp.h\u003e\n+#include \u003cnet/ip.h\u003e\n #include \u003cnet/ip6_checksum.h\u003e\n+#include \u003cnet/ipv6.h\u003e\n #include \u003clinux/bitfield.h\u003e\n #include \"rmnet_config.h\"\n #include \"rmnet_map.h\"\n@@ -17,6 +21,19 @@\n #define RMNET_MAP_DEAGGR_SPACING 64\n #define RMNET_MAP_DEAGGR_HEADROOM (RMNET_MAP_DEAGGR_SPACING / 2)\n \n+struct rmnet_map_coal_metadata {\n+\tvoid *ip_header;\n+\tvoid *trans_header;\n+\tu16 ip_len;\n+\tu16 trans_len;\n+\tu16 data_offset;\n+\tu16 data_len;\n+\tu8 ip_proto;\n+\tu8 trans_proto;\n+\tu8 pkt_count;\n+\tbool zero_csum;\n+};\n+\n static __sum16 *rmnet_map_get_csum_field(unsigned char protocol,\n \t\t\t\t\t const void *txporthdr)\n {\n@@ -36,34 +53,45 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb,\n {\n \tstruct iphdr *ip4h = (struct iphdr *)skb-\u003edata;\n \tvoid *txporthdr = skb-\u003edata + ip4h-\u003eihl * 4;\n+\tstruct rmnet_pcpu_stats *pcpu_ptr;\n \t__sum16 *csum_field, pseudo_csum;\n \t__sum16 ip_payload_csum;\n \n+\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\n+\n \t/* Computing the checksum over just the IPv4 header--including its\n \t * checksum field--should yield 0. If it doesn't, the IP header\n \t * is bad, so return an error and let the IP layer drop it.\n \t */\n \tif (ip_fast_csum(ip4h, ip4h-\u003eihl)) {\n-\t\tpriv-\u003estats.csum_ip4_header_bad++;\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_ip4_header_bad);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n \t\treturn -EINVAL;\n \t}\n \n \t/* We don't support checksum offload on IPv4 fragments */\n \tif (ip_is_fragment(ip4h)) {\n-\t\tpriv-\u003estats.csum_fragmented_pkt++;\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_fragmented_pkt);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n \t\treturn -EOPNOTSUPP;\n \t}\n \n \t/* Checksum offload is only supported for UDP and TCP protocols */\n \tcsum_field = rmnet_map_get_csum_field(ip4h-\u003eprotocol, txporthdr);\n \tif (!csum_field) {\n-\t\tpriv-\u003estats.csum_err_invalid_transport++;\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_err_invalid_transport);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n \t\treturn -EPROTONOSUPPORT;\n \t}\n \n \t/* RFC 768: UDP checksum is optional for IPv4, and is 0 if unused */\n \tif (!*csum_field \u0026\u0026 ip4h-\u003eprotocol == IPPROTO_UDP) {\n-\t\tpriv-\u003estats.csum_skipped++;\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_skipped);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n \t\treturn 0;\n \t}\n \n@@ -96,11 +124,15 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb,\n \n \t/* The cast is required to ensure only the low 16 bits are examined */\n \tif (ip_payload_csum != (__sum16)~pseudo_csum) {\n-\t\tpriv-\u003estats.csum_validation_failed++;\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_validation_failed);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n \t\treturn -EINVAL;\n \t}\n \n-\tpriv-\u003estats.csum_ok++;\n+\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_ok);\n+\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n \treturn 0;\n }\n \n@@ -112,16 +144,21 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb,\n {\n \tstruct ipv6hdr *ip6h = (struct ipv6hdr *)skb-\u003edata;\n \tvoid *txporthdr = skb-\u003edata + sizeof(*ip6h);\n+\tstruct rmnet_pcpu_stats *pcpu_ptr;\n \t__sum16 *csum_field, pseudo_csum;\n \t__sum16 ip6_payload_csum;\n \t__be16 ip_header_csum;\n \n+\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\n+\n \t/* Checksum offload is only supported for UDP and TCP protocols;\n \t * the packet cannot include any IPv6 extension headers\n \t */\n \tcsum_field = rmnet_map_get_csum_field(ip6h-\u003enexthdr, txporthdr);\n \tif (!csum_field) {\n-\t\tpriv-\u003estats.csum_err_invalid_transport++;\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_err_invalid_transport);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n \t\treturn -EPROTONOSUPPORT;\n \t}\n \n@@ -147,11 +184,15 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb,\n \t * examined.\n \t */\n \tif (ip6_payload_csum != (__sum16)~pseudo_csum) {\n-\t\tpriv-\u003estats.csum_validation_failed++;\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_validation_failed);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n \t\treturn -EINVAL;\n \t}\n \n-\tpriv-\u003estats.csum_ok++;\n+\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_ok);\n+\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n \treturn 0;\n }\n #else\n@@ -246,6 +287,9 @@ static void rmnet_map_v5_checksum_uplink_packet(struct sk_buff *skb,\n {\n \tstruct rmnet_priv *priv = netdev_priv(orig_dev);\n \tstruct rmnet_map_v5_csum_header *ul_header;\n+\tstruct rmnet_pcpu_stats *pcpu_ptr;\n+\n+\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\n \n \tul_header = skb_push(skb, sizeof(*ul_header));\n \tmemset(ul_header, 0, sizeof(*ul_header));\n@@ -270,7 +314,9 @@ static void rmnet_map_v5_checksum_uplink_packet(struct sk_buff *skb,\n \t\t\tproto = ((struct ipv6hdr *)iph)-\u003enexthdr;\n \t\t\ttrans = iph + ip_len;\n \t\t} else {\n-\t\t\tpriv-\u003estats.csum_err_invalid_ip_version++;\n+\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_err_invalid_ip_version);\n+\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n \t\t\tgoto sw_csum;\n \t\t}\n \n@@ -279,13 +325,17 @@ static void rmnet_map_v5_checksum_uplink_packet(struct sk_buff *skb,\n \t\t\tskb-\u003eip_summed = CHECKSUM_NONE;\n \t\t\t/* Ask for checksum offloading */\n \t\t\tul_header-\u003ecsum_info |= MAPV5_CSUMINFO_VALID_FLAG;\n-\t\t\tpriv-\u003estats.csum_hw++;\n+\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_hw);\n+\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n \t\t\treturn;\n \t\t}\n \t}\n \n sw_csum:\n-\tpriv-\u003estats.csum_sw++;\n+\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_sw);\n+\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n }\n \n /* Adds MAP header to front of skb-\u003edata\n@@ -337,8 +387,8 @@ u32 rmnet_map_validate_packet_len(struct sk_buff *skb, u32 data_format)\n {\n \tstruct rmnet_map_v5_csum_header *next_hdr = NULL;\n \tstruct rmnet_map_header *maph;\n-\tvoid *data = skb-\u003edata;\n \tu32 packet_len;\n+\tu8 hdr_type;\n \n \tif (skb-\u003elen \u003c sizeof(*maph))\n \t\treturn 0;\n@@ -353,24 +403,28 @@ u32 rmnet_map_validate_packet_len(struct sk_buff *skb, u32 data_format)\n \n \tif (data_format \u0026 RMNET_FLAGS_INGRESS_MAP_CKSUMV4) {\n \t\tpacket_len += sizeof(struct rmnet_map_dl_csum_trailer);\n-\t} else if ((data_format \u0026 RMNET_FLAGS_INGRESS_MAP_CKSUMV5) \u0026\u0026\n+\t} else if ((data_format \u0026\n+\t\t (RMNET_FLAGS_INGRESS_MAP_CKSUMV5 | RMNET_FLAGS_INGRESS_COALESCE)) \u0026\u0026\n \t\t !(maph-\u003eflags \u0026 MAP_CMD_FLAG)) {\n-\t\t/* Mapv5 data pkt without csum hdr is invalid */\n \t\tif (!(maph-\u003eflags \u0026 MAP_NEXT_HEADER_FLAG))\n \t\t\treturn 0;\n \n-\t\tpacket_len += sizeof(*next_hdr);\n-\t\tnext_hdr = data + sizeof(*maph);\n+\t\tif (skb-\u003elen \u003c sizeof(*maph) + sizeof(*next_hdr))\n+\t\t\treturn 0;\n+\n+\t\tnext_hdr = (struct rmnet_map_v5_csum_header *)(skb-\u003edata + sizeof(*maph));\n+\t\thdr_type = u8_get_bits(next_hdr-\u003eheader_info,\n+\t\t\t\t MAPV5_HDRINFO_HDR_TYPE_FMASK);\n+\n+\t\tif (hdr_type == RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD)\n+\t\t\tpacket_len += sizeof(*next_hdr);\n+\t\telse if (hdr_type != RMNET_MAP_HEADER_TYPE_COALESCING)\n+\t\t\treturn 0;\n \t}\n \n \tif (skb-\u003elen \u003c packet_len)\n \t\treturn 0;\n \n-\tif (next_hdr \u0026\u0026\n-\t u8_get_bits(next_hdr-\u003eheader_info, MAPV5_HDRINFO_HDR_TYPE_FMASK) !=\n-\t RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD)\n-\t\treturn 0;\n-\n \treturn packet_len;\n }\n \n@@ -413,16 +467,23 @@ int rmnet_map_checksum_downlink_packet(struct sk_buff *skb, u16 len)\n {\n \tstruct rmnet_priv *priv = netdev_priv(skb-\u003edev);\n \tstruct rmnet_map_dl_csum_trailer *csum_trailer;\n+\tstruct rmnet_pcpu_stats *pcpu_ptr;\n+\n+\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\n \n \tif (unlikely(!(skb-\u003edev-\u003efeatures \u0026 NETIF_F_RXCSUM))) {\n-\t\tpriv-\u003estats.csum_sw++;\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_sw);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n \t\treturn -EOPNOTSUPP;\n \t}\n \n \tcsum_trailer = (struct rmnet_map_dl_csum_trailer *)(skb-\u003edata + len);\n \n \tif (!(csum_trailer-\u003eflags \u0026 MAP_CSUM_DL_VALID_FLAG)) {\n-\t\tpriv-\u003estats.csum_valid_unset++;\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_valid_unset);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n \t\treturn -EINVAL;\n \t}\n \n@@ -432,7 +493,9 @@ int rmnet_map_checksum_downlink_packet(struct sk_buff *skb, u16 len)\n \tif (IS_ENABLED(CONFIG_IPV6) \u0026\u0026 skb-\u003eprotocol == htons(ETH_P_IPV6))\n \t\treturn rmnet_map_ipv6_dl_csum_trailer(skb, csum_trailer, priv);\n \n-\tpriv-\u003estats.csum_err_invalid_ip_version++;\n+\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_err_invalid_ip_version);\n+\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n \n \treturn -EPROTONOSUPPORT;\n }\n@@ -442,8 +505,11 @@ static void rmnet_map_v4_checksum_uplink_packet(struct sk_buff *skb,\n {\n \tstruct rmnet_priv *priv = netdev_priv(orig_dev);\n \tstruct rmnet_map_ul_csum_header *ul_header;\n+\tstruct rmnet_pcpu_stats *pcpu_ptr;\n \tvoid *iphdr;\n \n+\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\n+\n \tul_header = (struct rmnet_map_ul_csum_header *)\n \t\t skb_push(skb, sizeof(struct rmnet_map_ul_csum_header));\n \n@@ -459,22 +525,30 @@ static void rmnet_map_v4_checksum_uplink_packet(struct sk_buff *skb,\n \n \tif (skb-\u003eprotocol == htons(ETH_P_IP)) {\n \t\trmnet_map_ipv4_ul_csum_header(iphdr, ul_header, skb);\n-\t\tpriv-\u003estats.csum_hw++;\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_hw);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n \t\treturn;\n \t}\n \n \tif (IS_ENABLED(CONFIG_IPV6) \u0026\u0026 skb-\u003eprotocol == htons(ETH_P_IPV6)) {\n \t\trmnet_map_ipv6_ul_csum_header(iphdr, ul_header, skb);\n-\t\tpriv-\u003estats.csum_hw++;\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_hw);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n \t\treturn;\n \t}\n \n-\tpriv-\u003estats.csum_err_invalid_ip_version++;\n+\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_err_invalid_ip_version);\n+\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n \n sw_csum:\n \tmemset(ul_header, 0, sizeof(*ul_header));\n \n-\tpriv-\u003estats.csum_sw++;\n+\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_sw);\n+\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n }\n \n /* Generates UL checksum meta info header for IPv4 and IPv6 over TCP and UDP\n@@ -497,34 +571,847 @@ void rmnet_map_checksum_uplink_packet(struct sk_buff *skb,\n \t}\n }\n \n-/* Process a MAPv5 packet header */\n-int rmnet_map_process_next_hdr_packet(struct sk_buff *skb,\n-\t\t\t\t u16 len)\n+static struct rmnet_map_v5_csum_header *\n+rmnet_map_get_next_hdr(struct sk_buff *skb)\n {\n-\tstruct rmnet_priv *priv = netdev_priv(skb-\u003edev);\n-\tstruct rmnet_map_v5_csum_header *next_hdr;\n-\tu8 nexthdr_type;\n+\treturn (struct rmnet_map_v5_csum_header *)(skb-\u003edata +\n+\t\t\t\t\t\t sizeof(struct rmnet_map_header));\n+}\n+\n+static u8 rmnet_map_get_next_hdr_type(struct sk_buff *skb)\n+{\n+\tstruct rmnet_map_v5_csum_header *hdr = rmnet_map_get_next_hdr(skb);\n+\n+\treturn u8_get_bits(hdr-\u003eheader_info, MAPV5_HDRINFO_HDR_TYPE_FMASK);\n+}\n+\n+static bool rmnet_map_get_csum_valid(struct sk_buff *skb)\n+{\n+\tstruct rmnet_map_v5_csum_header *hdr = rmnet_map_get_next_hdr(skb);\n \n-\tnext_hdr = (struct rmnet_map_v5_csum_header *)(skb-\u003edata +\n-\t\t\tsizeof(struct rmnet_map_header));\n+\treturn !!(hdr-\u003ecsum_info \u0026 MAPV5_CSUMINFO_VALID_FLAG);\n+}\n+\n+/* Stamp GSO metadata so the network stack can segment a coalesced SKB. */\n+static void rmnet_map_gso_stamp(struct sk_buff *skb,\n+\t\t\t\tstruct rmnet_map_coal_metadata *coal_meta)\n+{\n+\tstruct skb_shared_info *shinfo = skb_shinfo(skb);\n \n-\tnexthdr_type = u8_get_bits(next_hdr-\u003eheader_info,\n-\t\t\t\t MAPV5_HDRINFO_HDR_TYPE_FMASK);\n+\tif (coal_meta-\u003etrans_proto == IPPROTO_TCP)\n+\t\tshinfo-\u003egso_type = (coal_meta-\u003eip_proto == 4) ?\n+\t\t\t\t SKB_GSO_TCPV4 : SKB_GSO_TCPV6;\n+\telse\n+\t\tshinfo-\u003egso_type = SKB_GSO_UDP_L4;\n \n-\tif (nexthdr_type != RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD)\n+\tshinfo-\u003egso_size = coal_meta-\u003edata_len;\n+\tshinfo-\u003egso_segs = coal_meta-\u003epkt_count;\n+}\n+\n+/* Set the transport checksum to the pseudo-header checksum and request\n+ * partial checksum offload, letting the NIC or stack finish it.\n+ */\n+static void rmnet_map_partial_csum(struct sk_buff *skb,\n+\t\t\t\t struct rmnet_map_coal_metadata *coal_meta)\n+{\n+\tu16 pkt_len = skb-\u003elen - coal_meta-\u003eip_len;\n+\tunsigned char *data = skb-\u003edata;\n+\t__sum16 pseudo;\n+\n+\tif (coal_meta-\u003eip_proto == 4) {\n+\t\tstruct iphdr *iph = (struct iphdr *)data;\n+\n+\t\tpseudo = ~csum_tcpudp_magic(iph-\u003esaddr, iph-\u003edaddr,\n+\t\t\t\t\t pkt_len, coal_meta-\u003etrans_proto, 0);\n+\t} else {\n+\t\tstruct ipv6hdr *ip6h = (struct ipv6hdr *)data;\n+\n+\t\tpseudo = ~csum_ipv6_magic(\u0026ip6h-\u003esaddr, \u0026ip6h-\u003edaddr,\n+\t\t\t\t\t pkt_len, coal_meta-\u003etrans_proto, 0);\n+\t}\n+\n+\tif (coal_meta-\u003etrans_proto == IPPROTO_TCP) {\n+\t\tstruct tcphdr *tp = (struct tcphdr *)(data + coal_meta-\u003eip_len);\n+\n+\t\ttp-\u003echeck = pseudo;\n+\t\tskb-\u003ecsum_offset = offsetof(struct tcphdr, check);\n+\t} else {\n+\t\tstruct udphdr *up = (struct udphdr *)(data + coal_meta-\u003eip_len);\n+\n+\t\tup-\u003echeck = pseudo;\n+\t\tskb-\u003ecsum_offset = offsetof(struct udphdr, check);\n+\t}\n+\n+\tskb-\u003eip_summed = CHECKSUM_PARTIAL;\n+\tskb-\u003ecsum_start = skb-\u003edata + coal_meta-\u003eip_len - skb-\u003ehead;\n+}\n+\n+/* On some hardware, num_nlos in the coalescing header can be reported\n+ * incorrectly under certain conditions even though the per-NLO num_packets\n+ * fields it is meant to summarize are correct. Recompute the NLO count from\n+ * the contiguous nl_pairs[] prefix rather than trusting the declared value.\n+ * The first empty NLO marks the end of the prefix. Entries after it are not\n+ * processed.\n+ */\n+static int rmnet_map_v5_get_num_nlos(const struct rmnet_map_v5_coal_header *coal_hdr)\n+{\n+\tint nlos;\n+\n+\tfor (nlos = 0; nlos \u003c RMNET_MAP_V5_MAX_NLOS; nlos++)\n+\t\tif (!coal_hdr-\u003enl_pairs[nlos].num_packets)\n+\t\t\tbreak;\n+\n+\tif (!nlos)\n \t\treturn -EINVAL;\n \n-\tif (unlikely(!(skb-\u003edev-\u003efeatures \u0026 NETIF_F_RXCSUM))) {\n-\t\tpriv-\u003estats.csum_sw++;\n-\t} else if (next_hdr-\u003ecsum_info \u0026 MAPV5_CSUMINFO_VALID_FLAG) {\n-\t\tpriv-\u003estats.csum_ok++;\n-\t\tskb-\u003eip_summed = CHECKSUM_UNNECESSARY;\n+\treturn nlos;\n+}\n+\n+static void rmnet_map_v5_set_nlos(struct rmnet_map_v5_coal_header *coal_hdr,\n+\t\t\t\t u8 nlos)\n+{\n+\tcoal_hdr-\u003ecoal_info = u8_encode_bits(nlos, MAPV5_COALINFO_NUM_NLOS_FMASK) |\n+\t\t\t\t (coal_hdr-\u003ecoal_info \u0026 MAPV5_COALINFO_CSUM_VALID_FLAG);\n+}\n+\n+/* The frame-level CSUM_VALID indication for a single NLO, single packet\n+ * coalescing frame cannot be trusted when the close reason is a TCP FIN/PSH,\n+ * a packet count limit, a byte count limit or a time limit.\n+ */\n+static bool rmnet_map_v5_csum_fixup(struct rmnet_map_v5_coal_header *coal_hdr)\n+{\n+\tu8 close_value = u8_get_bits(coal_hdr-\u003eclose_info,\n+\t\t\t\t MAPV5_CLOSEINFO_CLOSE_VALUE_FMASK);\n+\tu8 close_type = u8_get_bits(coal_hdr-\u003eclose_info,\n+\t\t\t\t MAPV5_CLOSEINFO_CLOSE_TYPE_FMASK);\n+\tu8 num_nlos = u8_get_bits(coal_hdr-\u003ecoal_info,\n+\t\t\t\t MAPV5_COALINFO_NUM_NLOS_FMASK);\n+\n+\t/* Only applies to single NLO, single packet frames */\n+\tif (num_nlos != 1 || coal_hdr-\u003enl_pairs[0].num_packets != 1)\n+\t\treturn false;\n+\n+\t/* TCP FIN or PSH triggered the close */\n+\tif (close_type == RMNET_MAP_COAL_CLOSE_COAL)\n+\t\treturn true;\n+\n+\t/* Hit a hardware limit */\n+\tif (close_type == RMNET_MAP_COAL_CLOSE_HW) {\n+\t\tswitch (close_value) {\n+\t\tcase RMNET_MAP_COAL_CLOSE_HW_PKT:\n+\t\tcase RMNET_MAP_COAL_CLOSE_HW_BYTE:\n+\t\tcase RMNET_MAP_COAL_CLOSE_HW_TIME:\n+\t\t\treturn true;\n+\t\t}\n+\t}\n+\n+\treturn false;\n+}\n+\n+/* Carve one logical segment from a coalesced SKB and append it to the list.\n+ * Adjusts TCP sequence numbers, IP IDs/lengths, and checksum state.\n+ */\n+static void\n+__rmnet_map_segment_coal_skb(struct sk_buff *coal_skb,\n+\t\t\t struct rmnet_map_coal_metadata *coal_meta,\n+\t\t\t struct sk_buff_head *list, u8 pkt_id,\n+\t\t\t bool csum_valid)\n+{\n+\tu32 dlen = coal_meta-\u003edata_len * coal_meta-\u003epkt_count;\n+\tstruct rmnet_priv *priv = netdev_priv(coal_skb-\u003edev);\n+\tu32 hlen = coal_meta-\u003eip_len + coal_meta-\u003etrans_len;\n+\tstruct rmnet_pcpu_stats *pcpu_ptr;\n+\tstruct sk_buff *skbn;\n+\n+\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\n+\n+\t/* RFC 768: UDP checksum is optional for IPv4, and is 0 if unused.\n+\t * Such packets are never actually bad, regardless of what the\n+\t * checksum bitmap says.\n+\t */\n+\tif (!csum_valid \u0026\u0026 coal_meta-\u003ezero_csum)\n+\t\tcsum_valid = true;\n+\n+\tif (!csum_valid) {\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t/* rx_dropped is standard accounting. coal_csum_drop is its\n+\t\t * coalescing-specific checksum error subset.\n+\t\t */\n+\t\tu64_stats_add(\u0026pcpu_ptr-\u003epriv_stats.rx_dropped, coal_meta-\u003epkt_count);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_csum_drop);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\tgoto next_pkt;\n+\t}\n+\n+\tskbn = alloc_skb(hlen + dlen + RMNET_MAP_DEAGGR_HEADROOM, GFP_ATOMIC);\n+\tif (!skbn) {\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t/* The coal counter is the coalescing subset of the standard\n+\t\t * allocation failure and RX drop counters.\n+\t\t */\n+\t\tu64_stats_add(\u0026pcpu_ptr-\u003epriv_stats.rx_alloc_fail, coal_meta-\u003epkt_count);\n+\t\tu64_stats_add(\u0026pcpu_ptr-\u003epriv_stats.rx_dropped, coal_meta-\u003epkt_count);\n+\t\tu64_stats_add(\u0026pcpu_ptr-\u003epriv_stats.coal_alloc_fail, coal_meta-\u003epkt_count);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\tgoto next_pkt;\n+\t}\n+\n+\tskb_reserve(skbn, hlen + RMNET_MAP_DEAGGR_HEADROOM);\n+\tskb_put_data(skbn,\n+\t\t coal_skb-\u003edata + coal_meta-\u003eip_len + coal_meta-\u003etrans_len +\n+\t\t coal_meta-\u003edata_offset,\n+\t\t dlen);\n+\n+\t/* Restore transport header */\n+\tskb_push(skbn, coal_meta-\u003etrans_len);\n+\tmemcpy(skbn-\u003edata, coal_meta-\u003etrans_header, coal_meta-\u003etrans_len);\n+\tskb_reset_transport_header(skbn);\n+\n+\tif (coal_meta-\u003etrans_proto == IPPROTO_TCP) {\n+\t\tstruct tcphdr *th = tcp_hdr(skbn);\n+\n+\t\tth-\u003eseq = htonl(ntohl(th-\u003eseq) + coal_meta-\u003edata_offset);\n+\t\t/* Strip dangerous flags from non-final segments */\n+\t\tif ((th-\u003efin || th-\u003epsh) \u0026\u0026\n+\t\t hlen + coal_meta-\u003edata_offset + dlen \u003c coal_skb-\u003elen) {\n+\t\t\tth-\u003efin = 0;\n+\t\t\tth-\u003epsh = 0;\n+\t\t}\n+\t} else if (coal_meta-\u003etrans_proto == IPPROTO_UDP) {\n+\t\tstruct udphdr *uh = udp_hdr(skbn);\n+\n+\t\tuh-\u003elen = htons(skbn-\u003elen);\n+\t}\n+\n+\t/* Restore IP header */\n+\tskb_push(skbn, coal_meta-\u003eip_len);\n+\tmemcpy(skbn-\u003edata, coal_meta-\u003eip_header, coal_meta-\u003eip_len);\n+\tskb_reset_network_header(skbn);\n+\n+\tif (coal_meta-\u003eip_proto == 4) {\n+\t\tstruct iphdr *iph = ip_hdr(skbn);\n+\n+\t\tiph-\u003eid = htons(ntohs(iph-\u003eid) + pkt_id);\n+\t\tiph-\u003etot_len = htons(skbn-\u003elen);\n+\t\tiph-\u003echeck = 0;\n+\t\tiph-\u003echeck = ip_fast_csum(iph, iph-\u003eihl);\n+\t} else {\n+\t\tipv6_hdr(skbn)-\u003epayload_len =\n+\t\t\thtons(skbn-\u003elen - sizeof(struct ipv6hdr));\n+\t}\n+\n+\trmnet_map_partial_csum(skbn, coal_meta);\n+\n+\tskbn-\u003edev = coal_skb-\u003edev;\n+\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_reconstruct);\n+\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\n+\tif (coal_meta-\u003epkt_count \u003e 1)\n+\t\trmnet_map_gso_stamp(skbn, coal_meta);\n+\n+\t__skb_queue_tail(list, skbn);\n+\n+next_pkt:\n+\tcoal_meta-\u003edata_offset += dlen;\n+\tcoal_meta-\u003epkt_count = 0;\n+}\n+\n+/* Parse the IP header of the coalesced frame and perform basic\n+ * validation of header fields.\n+ */\n+static bool rmnet_map_coal_parse_ip_hdr(struct sk_buff *coal_skb,\n+\t\t\t\t\tstruct rmnet_map_coal_metadata *meta,\n+\t\t\t\t\tbool *gro)\n+{\n+\tstruct rmnet_priv *priv = netdev_priv(coal_skb-\u003edev);\n+\tstruct rmnet_pcpu_stats *pcpu_ptr;\n+\tstruct ipv6hdr *ip6h;\n+\tstruct iphdr *iph;\n+\t__be16 frag_off;\n+\tu8 protocol;\n+\tint ret;\n+\n+\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\n+\n+\tif (coal_skb-\u003elen \u003c sizeof(*iph)) {\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_ip_invalid);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\treturn false;\n+\t}\n+\n+\tiph = (struct iphdr *)coal_skb-\u003edata;\n+\n+\tif (iph-\u003eversion == 4) {\n+\t\tmeta-\u003eip_proto = 4;\n+\t\tmeta-\u003eip_len = iph-\u003eihl * 4;\n+\t\tmeta-\u003etrans_proto = iph-\u003eprotocol;\n+\t\tmeta-\u003eip_header = iph;\n+\t\tif (meta-\u003eip_len \u003c sizeof(*iph) || coal_skb-\u003elen \u003c meta-\u003eip_len) {\n+\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_ip_invalid);\n+\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tif (ip_is_fragment(iph)) {\n+\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_ip_invalid);\n+\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tif (iph-\u003eihl != 5)\n+\t\t\t*gro = false;\n+\t} else if (iph-\u003eversion == 6) {\n+\t\tif (coal_skb-\u003elen \u003c sizeof(*ip6h)) {\n+\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_ip_invalid);\n+\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tip6h = (struct ipv6hdr *)iph;\n+\t\tprotocol = ip6h-\u003enexthdr;\n+\t\tmeta-\u003eip_proto = 6;\n+\t\tret = ipv6_skip_exthdr(coal_skb, sizeof(*ip6h), \u0026protocol,\n+\t\t\t\t \u0026frag_off);\n+\t\tif (ret \u003c 0 || frag_off || ret \u003e U16_MAX) {\n+\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_ip_invalid);\n+\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tmeta-\u003eip_len = (u16)ret;\n+\t\tmeta-\u003etrans_proto = protocol;\n+\t\tmeta-\u003eip_header = ip6h;\n+\t\tif (coal_skb-\u003elen \u003c meta-\u003eip_len) {\n+\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_ip_invalid);\n+\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tif (meta-\u003eip_len \u003e sizeof(*ip6h))\n+\t\t\t*gro = false;\n+\t} else {\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_ip_invalid);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\treturn false;\n+\t}\n+\n+\treturn true;\n+}\n+\n+/* Parse the transport header following the IP header into coal_meta. The\n+ * available length is checked before any field is read.\n+ */\n+static bool rmnet_map_coal_parse_trans_hdr(struct sk_buff *coal_skb,\n+\t\t\t\t\t struct rmnet_map_coal_metadata *meta)\n+{\n+\tstruct rmnet_priv *priv = netdev_priv(coal_skb-\u003edev);\n+\tstruct rmnet_pcpu_stats *pcpu_ptr;\n+\tstruct udphdr *uh;\n+\tstruct tcphdr *th;\n+\tu32 avail;\n+\tu8 *base;\n+\n+\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\n+\n+\tif (meta-\u003eip_len \u003e coal_skb-\u003elen) {\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_trans_invalid);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\treturn false;\n+\t}\n+\n+\tbase = (u8 *)meta-\u003eip_header + meta-\u003eip_len;\n+\tavail = coal_skb-\u003elen - meta-\u003eip_len;\n+\n+\tif (meta-\u003etrans_proto == IPPROTO_TCP) {\n+\t\tif (avail \u003c sizeof(*th)) {\n+\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_trans_invalid);\n+\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tth = (struct tcphdr *)base;\n+\t\tmeta-\u003etrans_len = th-\u003edoff * 4;\n+\t\tmeta-\u003etrans_header = th;\n+\t\tif (meta-\u003etrans_len \u003c sizeof(*th) || avail \u003c meta-\u003etrans_len) {\n+\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_trans_invalid);\n+\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\treturn false;\n+\t\t}\n+\t} else if (meta-\u003etrans_proto == IPPROTO_UDP) {\n+\t\tif (avail \u003c sizeof(*uh)) {\n+\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_trans_invalid);\n+\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tuh = (struct udphdr *)base;\n+\t\tmeta-\u003etrans_len = sizeof(*uh);\n+\t\tmeta-\u003etrans_header = uh;\n+\t\tif (meta-\u003eip_proto == 4 \u0026\u0026 !uh-\u003echeck)\n+\t\t\tmeta-\u003ezero_csum = true;\n \t} else {\n-\t\tpriv-\u003estats.csum_valid_unset++;\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_trans_invalid);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\treturn false;\n+\t}\n+\n+\treturn true;\n+}\n+\n+/* Reject the frame unless the total data bytes claimed by all NLOs\n+ * exactly match the actual payload in the SKB. Each pkt_len covers\n+ * IP+transport headers plus per-packet data. Headers appear once, so\n+ * subtract hlen per packet and track the running sum against available\n+ * data. An exact match is required, not just an upper bound, so that\n+ * GSO metadata stamped from the NLOs stays consistent with the real\n+ * SKB length.\n+ */\n+static bool rmnet_map_coal_validate_bounds(struct sk_buff *coal_skb,\n+\t\t\t\t\t struct rmnet_map_v5_coal_header *coal_hdr,\n+\t\t\t\t\t u8 num_nlos, u32 hlen, bool *gro)\n+{\n+\tu32 total_data = 0;\n+\tu32 nlo_len;\n+\tu16 plen;\n+\tu8 i;\n+\n+\tif (hlen \u003e coal_skb-\u003elen)\n+\t\treturn false;\n+\n+\tfor (i = 0; i \u003c num_nlos; i++) {\n+\t\tplen = ntohs(coal_hdr-\u003enl_pairs[i].pkt_len);\n+\n+\t\tif (plen \u003c hlen)\n+\t\t\treturn false;\n+\n+\t\t/* Zero-payload packets cannot use GSO with a zero gso_size. */\n+\t\tif (plen == hlen)\n+\t\t\t*gro = false;\n+\n+\t\tnlo_len = (u32)(plen - hlen) * coal_hdr-\u003enl_pairs[i].num_packets;\n+\t\tif (nlo_len \u003e coal_skb-\u003elen - hlen - total_data)\n+\t\t\treturn false;\n+\n+\t\ttotal_data += nlo_len;\n+\t}\n+\n+\treturn total_data == coal_skb-\u003elen - hlen;\n+}\n+\n+/* Attempt the GRO-friendly fast path for a single-NLO, checksum-valid frame\n+ * by reusing the original SKB and stamping GSO metadata instead of copying\n+ * out each segment. Returns true if the frame was consumed via the fast\n+ * path, or false if the caller should fall back to full segmentation.\n+ */\n+static bool rmnet_map_coal_gro_fast_path(struct sk_buff *coal_skb,\n+\t\t\t\t\t struct rmnet_map_v5_coal_header *coal_hdr,\n+\t\t\t\t\t struct rmnet_map_coal_metadata *coal_meta,\n+\t\t\t\t\t struct sk_buff_head *list,\n+\t\t\t\t\t u8 num_nlos, bool gro)\n+{\n+\tu32 hlen = coal_meta-\u003eip_len + coal_meta-\u003etrans_len;\n+\n+\tif (!gro || num_nlos != 1 ||\n+\t !(coal_hdr-\u003ecoal_info \u0026 MAPV5_COALINFO_CSUM_VALID_FLAG))\n+\t\treturn false;\n+\n+\tcoal_meta-\u003edata_len = ntohs(coal_hdr-\u003enl_pairs[0].pkt_len) - hlen;\n+\tcoal_meta-\u003epkt_count = coal_hdr-\u003enl_pairs[0].num_packets;\n+\n+\tcoal_skb-\u003eip_summed = CHECKSUM_UNNECESSARY;\n+\tif (coal_meta-\u003epkt_count \u003e 1) {\n+\t\trmnet_map_partial_csum(coal_skb, coal_meta);\n+\t\trmnet_map_gso_stamp(coal_skb, coal_meta);\n+\t}\n+\n+\t__skb_queue_tail(list, coal_skb);\n+\treturn true;\n+}\n+\n+/* NLO packet lengths are already bounds-checked by\n+ * rmnet_map_coal_validate_bounds() so no further validation is needed here.\n+ */\n+static void rmnet_map_coal_segment_loop(struct sk_buff *coal_skb,\n+\t\t\t\t\tstruct rmnet_map_v5_coal_header *coal_hdr,\n+\t\t\t\t\tstruct rmnet_map_coal_metadata *coal_meta,\n+\t\t\t\t\tstruct sk_buff_head *list,\n+\t\t\t\t\tu64 nlo_err_mask, bool gro, u8 num_nlos)\n+{\n+\tstruct rmnet_priv *priv = netdev_priv(coal_skb-\u003edev);\n+\tu32 hlen = coal_meta-\u003eip_len + coal_meta-\u003etrans_len;\n+\tstruct rmnet_pcpu_stats *pcpu_ptr;\n+\tu8 pkt, total_pkt = 0;\n+\tbool csum_err;\n+\tu16 pkt_len;\n+\tu8 nlo;\n+\n+\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\n+\n+\tfor (nlo = 0; nlo \u003c num_nlos; nlo++) {\n+\t\tpkt_len = ntohs(coal_hdr-\u003enl_pairs[nlo].pkt_len);\n+\t\tpkt_len -= hlen;\n+\t\tcoal_meta-\u003edata_len = pkt_len;\n+\n+\t\t/* nlo_err_mask is one flat bitstream across all NLOs. Shift\n+\t\t * it once per packet in absolute frame order and do not\n+\t\t * re-align at the NLO boundary above. See the comment on\n+\t\t * rmnet_map_data_check_coal_header() for why.\n+\t\t */\n+\t\tfor (pkt = 0; pkt \u003c coal_hdr-\u003enl_pairs[nlo].num_packets;\n+\t\t pkt++, total_pkt++, nlo_err_mask \u003e\u003e= 1) {\n+\t\t\tcsum_err = nlo_err_mask \u0026 1;\n+\n+\t\t\tif (csum_err) {\n+\t\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_csum_err);\n+\t\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\t}\n+\n+\t\t\tif (!gro) {\n+\t\t\t\tcoal_meta-\u003epkt_count = 1;\n+\t\t\t\t__rmnet_map_segment_coal_skb(coal_skb, coal_meta,\n+\t\t\t\t\t\t\t list, total_pkt,\n+\t\t\t\t\t\t\t !csum_err);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n+\t\t\tif (csum_err) {\n+\t\t\t\tif (coal_meta-\u003epkt_count)\n+\t\t\t\t\t__rmnet_map_segment_coal_skb(coal_skb,\n+\t\t\t\t\t\t\t\t coal_meta,\n+\t\t\t\t\t\t\t\t list,\n+\t\t\t\t\t\t\t\t total_pkt -\n+\t\t\t\t\t\t\t\t coal_meta-\u003epkt_count,\n+\t\t\t\t\t\t\t\t true);\n+\t\t\t\tcoal_meta-\u003epkt_count = 1;\n+\t\t\t\t__rmnet_map_segment_coal_skb(coal_skb, coal_meta,\n+\t\t\t\t\t\t\t list, total_pkt,\n+\t\t\t\t\t\t\t false);\n+\t\t\t} else {\n+\t\t\t\tcoal_meta-\u003epkt_count++;\n+\t\t\t}\n+\t\t}\n+\n+\t\t/* Flush remaining packets from this NLO */\n+\t\tif (coal_meta-\u003epkt_count)\n+\t\t\t__rmnet_map_segment_coal_skb(coal_skb, coal_meta, list,\n+\t\t\t\t\t\t total_pkt - coal_meta-\u003epkt_count, true);\n+\t}\n+}\n+\n+/* Expand a coalesced SKB into individual IP packets placed on the list.\n+ * NLOs with checksum errors are dropped. __rmnet_map_ingress_handler will\n+ * free the SKB in the error case.\n+ */\n+static int rmnet_map_segment_coal_skb(struct sk_buff *coal_skb,\n+\t\t\t\t u64 nlo_err_mask,\n+\t\t\t\t struct sk_buff_head *list,\n+\t\t\t\t u16 len, u16 total_pkts, u8 num_nlos)\n+{\n+\tbool gro_hw = coal_skb-\u003edev-\u003efeatures \u0026 NETIF_F_GRO_HW;\n+\tbool rxcsum = coal_skb-\u003edev-\u003efeatures \u0026 NETIF_F_RXCSUM;\n+\tstruct rmnet_priv *priv = netdev_priv(coal_skb-\u003edev);\n+\tstruct rmnet_map_v5_coal_header *coal_hdr;\n+\tstruct rmnet_map_coal_metadata coal_meta;\n+\tstruct rmnet_pcpu_stats *pcpu_ptr;\n+\tbool gro = gro_hw;\n+\tu32 hlen;\n+\n+\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\n+\n+\tmemset(\u0026coal_meta, 0, sizeof(coal_meta));\n+\n+\t/* Drop any MAP frame padding. The coal header is counted in len */\n+\tskb_pull(coal_skb, sizeof(struct rmnet_map_header));\n+\tskb_trim(coal_skb, len);\n+\tcoal_hdr = (struct rmnet_map_v5_coal_header *)coal_skb-\u003edata;\n+\trmnet_map_v5_set_nlos(coal_hdr, num_nlos);\n+\tskb_pull(coal_skb, sizeof(*coal_hdr));\n+\n+\tif (!rmnet_map_coal_parse_ip_hdr(coal_skb, \u0026coal_meta, \u0026gro))\n+\t\treturn -EINVAL;\n+\n+\tif (!rmnet_map_coal_parse_trans_hdr(coal_skb, \u0026coal_meta))\n+\t\treturn -EINVAL;\n+\n+\thlen = coal_meta.ip_len + coal_meta.trans_len;\n+\n+\tif (!rmnet_map_coal_validate_bounds(coal_skb, coal_hdr, num_nlos, hlen,\n+\t\t\t\t\t \u0026gro)) {\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_bounds_err);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* Device capability gates coalesced delivery. Packet format can still\n+\t * disable GSO and use the per-packet fallback below.\n+\t */\n+\tif (total_pkts \u003e 1 \u0026\u0026 (!rxcsum || !gro_hw))\n+\t\treturn -EINVAL;\n+\n+\tif (gro \u0026\u0026 total_pkts \u003e 1) {\n+\t\t/* Standard counters cover delivered HW-GRO skbs. coal_rx and\n+\t\t * coal_pkts cover coalescing input regardless of HW-GRO.\n+\t\t */\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.rx_hw_gro_packets);\n+\t\tu64_stats_add(\u0026pcpu_ptr-\u003epriv_stats.rx_hw_gro_wire_packets, total_pkts);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t}\n+\n+\tif (total_pkts == 1 \u0026\u0026 (!rxcsum || !gro_hw)) {\n+\t\tcoal_skb-\u003eip_summed = CHECKSUM_NONE;\n+\t\t__skb_queue_tail(list, coal_skb);\n+\t\treturn 0;\n+\t}\n+\n+\tif (rmnet_map_v5_csum_fixup(coal_hdr) \u0026\u0026 !coal_meta.zero_csum) {\n+\t\tcoal_skb-\u003eip_summed = CHECKSUM_NONE;\n+\t\t__skb_queue_tail(list, coal_skb);\n+\t\treturn 0;\n+\t}\n+\n+\tif (rmnet_map_coal_gro_fast_path(coal_skb, coal_hdr, \u0026coal_meta, list,\n+\t\t\t\t\t num_nlos, gro))\n+\t\treturn 0;\n+\n+\trmnet_map_coal_segment_loop(coal_skb, coal_hdr, \u0026coal_meta, list,\n+\t\t\t\t nlo_err_mask, gro, num_nlos);\n+\n+\treturn 0;\n+}\n+\n+/* Log the hardware close-reason counter for a coalescing header. */\n+static void rmnet_map_data_log_close_stats(struct rmnet_pcpu_stats *pcpu_ptr,\n+\t\t\t\t\t u8 type, u8 code)\n+{\n+\tswitch (type) {\n+\tcase RMNET_MAP_COAL_CLOSE_NON_COAL:\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_close_non_coal);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\tbreak;\n+\tcase RMNET_MAP_COAL_CLOSE_IP_MISS:\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_close_ip_miss);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\tbreak;\n+\tcase RMNET_MAP_COAL_CLOSE_TRANS_MISS:\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_close_trans_miss);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\tbreak;\n+\tcase RMNET_MAP_COAL_CLOSE_HW:\n+\t\tswitch (code) {\n+\t\tcase RMNET_MAP_COAL_CLOSE_HW_NL:\n+\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_close_hw_nl);\n+\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tbreak;\n+\t\tcase RMNET_MAP_COAL_CLOSE_HW_PKT:\n+\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_close_hw_pkt);\n+\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tbreak;\n+\t\tcase RMNET_MAP_COAL_CLOSE_HW_BYTE:\n+\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_close_hw_byte);\n+\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tbreak;\n+\t\tcase RMNET_MAP_COAL_CLOSE_HW_TIME:\n+\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_close_hw_time);\n+\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tbreak;\n+\t\tcase RMNET_MAP_COAL_CLOSE_HW_EVICT:\n+\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_close_hw_evict);\n+\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tbreak;\n+\t\t}\n+\t\tbreak;\n+\tcase RMNET_MAP_COAL_CLOSE_COAL:\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_close_coal);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\tbreak;\n+\tdefault:\n+\t\tbreak;\n \t}\n+}\n \n-\t/* Pull csum v5 header */\n-\tskb_pull(skb, sizeof(*next_hdr));\n+/* Validate the coalescing header and build the checksum error mask.\n+ *\n+ * Checks performed:\n+ * - MAP pkt_len accommodates the coal header (coal header is counted in\n+ * pkt_len. pkt_len \u003c sizeof(*coal_hdr) means no payload is possible).\n+ * - num_nlos is in [1, RMNET_MAP_V5_MAX_NLOS].\n+ * - Total packet count does not exceed RMNET_MAP_V5_MAX_PACKETS.\n+ *\n+ * nlo_err_mask is NOT six independent per-NLO bitmaps. Each nl_pairs\n+ * slot only has room for an 8 bit csum_error_bitmap, but a single NLO\n+ * can carry more than 8 packets (up to RMNET_MAP_V5_MAX_PACKETS), so\n+ * hardware spills a wide NLO's error bits into the csum_error_bitmap\n+ * bytes of the following slots rather than truncating them. The\n+ * six bitmap bytes are therefore always concatenated in slot order\n+ * into one flat RMNET_MAP_V5_MAX_NLOS * 8 = RMNET_MAP_V5_MAX_PACKETS\n+ * bit value, addressed by a packet's absolute position in the frame,\n+ * regardless of how many NLOs are actually in use. Receivers must\n+ * walk it as a single contiguous stream and must not expect it to\n+ * align it at NLO boundaries.\n+ */\n+static int rmnet_map_data_check_coal_header(struct sk_buff *skb,\n+\t\t\t\t\t u64 *nlo_err_mask,\n+\t\t\t\t\t u8 *num_nlos,\n+\t\t\t\t\t u16 *num_pkts)\n+{\n+\tstruct rmnet_map_header *maph = (struct rmnet_map_header *)skb-\u003edata;\n+\tstruct rmnet_priv *priv = netdev_priv(skb-\u003edev);\n+\tstruct rmnet_map_v5_coal_header *coal_hdr;\n+\tstruct rmnet_pcpu_stats *pcpu_ptr;\n+\tu16 pkts = 0;\n+\tu64 mask = 0;\n+\tint nlos;\n+\tint i;\n+\n+\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\n+\n+\t/* coal header is counted in pkt_len */\n+\tif (ntohs(maph-\u003epkt_len) \u003c sizeof(*coal_hdr)) {\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_hdr_err);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tcoal_hdr = (struct rmnet_map_v5_coal_header *)(skb-\u003edata + sizeof(*maph));\n+\tnlos = rmnet_map_v5_get_num_nlos(coal_hdr);\n+\tif (nlos \u003c 0) {\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_hdr_err);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t*num_nlos = nlos;\n+\tfor (i = 0; i \u003c RMNET_MAP_V5_MAX_NLOS; i++) {\n+\t\tu8 err = coal_hdr-\u003enl_pairs[i].csum_error_bitmap;\n+\t\tu8 pkt = coal_hdr-\u003enl_pairs[i].num_packets;\n+\n+\t\tmask |= ((u64)err) \u003c\u003c (8 * i);\n+\t\tif (i \u003c *num_nlos) {\n+\t\t\tpkts += pkt;\n+\t\t\tif (pkts \u003e RMNET_MAP_V5_MAX_PACKETS) {\n+\t\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_hdr_pkt_err);\n+\t\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\t\treturn -EINVAL;\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\t/* coal_pkts counts packets reported by the hardware, independent of\n+\t * whether the frame is later delivered through HW-GRO.\n+\t */\n+\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\tu64_stats_add(\u0026pcpu_ptr-\u003epriv_stats.coal_pkts, pkts);\n+\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\trmnet_map_data_log_close_stats(pcpu_ptr,\n+\t\t\t\t u8_get_bits(coal_hdr-\u003eclose_info,\n+\t\t\t\t\t\t MAPV5_CLOSEINFO_CLOSE_TYPE_FMASK),\n+\t\t\t\t u8_get_bits(coal_hdr-\u003eclose_info,\n+\t\t\t\t\t\t MAPV5_CLOSEINFO_CLOSE_VALUE_FMASK));\n+\n+\t*nlo_err_mask = mask;\n+\t*num_pkts = pkts;\n+\treturn 0;\n+}\n+\n+int rmnet_map_process_next_hdr_packet(struct sk_buff *skb,\n+\t\t\t\t struct sk_buff_head *list,\n+\t\t\t\t u16 len, u32 data_format)\n+{\n+\tstruct rmnet_priv *priv = netdev_priv(skb-\u003edev);\n+\tstruct rmnet_pcpu_stats *pcpu_ptr;\n+\tu64 nlo_err_mask;\n+\tu16 num_pkts;\n+\tu8 num_nlos;\n+\tint rc;\n+\n+\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\n+\n+\tswitch (rmnet_map_get_next_hdr_type(skb)) {\n+\tcase RMNET_MAP_HEADER_TYPE_COALESCING:\n+\t\tif (!(data_format \u0026 RMNET_FLAGS_INGRESS_COALESCE))\n+\t\t\treturn -EINVAL;\n+\n+\t\t/* coal_rx counts coalescing input, not delivered HW-GRO skbs. */\n+\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_rx);\n+\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\trc = rmnet_map_data_check_coal_header(skb, \u0026nlo_err_mask,\n+\t\t\t\t\t\t \u0026num_nlos, \u0026num_pkts);\n+\t\tif (rc)\n+\t\t\treturn rc;\n+\n+\t\t/* Coalescing rewrites shared packet data and GSO metadata. */\n+\t\tif (skb_unclone(skb, GFP_ATOMIC))\n+\t\t\treturn -ENOMEM;\n+\n+\t\trc = rmnet_map_segment_coal_skb(skb, nlo_err_mask, list, len,\n+\t\t\t\t\t\tnum_pkts, num_nlos);\n+\t\tif (rc)\n+\t\t\treturn rc;\n+\n+\t\tif (skb_peek(list) != skb) {\n+\t\t\tif (skb_queue_empty(list))\n+\t\t\t\tkfree_skb(skb);\n+\t\t\telse\n+\t\t\t\tconsume_skb(skb);\n+\t\t}\n+\t\tbreak;\n+\n+\tcase RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD:\n+\t\tif (unlikely(!(skb-\u003edev-\u003efeatures \u0026 NETIF_F_RXCSUM))) {\n+\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_sw);\n+\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\t} else if (rmnet_map_get_csum_valid(skb)) {\n+\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_ok);\n+\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tskb-\u003eip_summed = CHECKSUM_UNNECESSARY;\n+\t\t} else {\n+\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.csum_valid_unset);\n+\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n+\t\t}\n+\n+\t\tskb_pull(skb, sizeof(struct rmnet_map_header) +\n+\t\t\t sizeof(struct rmnet_map_v5_csum_header));\n+\t\tskb_trim(skb, len);\n+\t\t__skb_queue_tail(list, skb);\n+\t\tbreak;\n+\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n \n \treturn 0;\n }\ndiff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c\nindex 5f921cddf82b4..8e2a83ca02355 100644\n--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c\n+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c\n@@ -7,6 +7,7 @@\n #include \u003clinux/capability.h\u003e\n #include \u003clinux/etherdevice.h\u003e\n #include \u003clinux/ethtool.h\u003e\n+#include \u003cnet/netdev_queues.h\u003e\n #include \u003clinux/if_arp.h\u003e\n #include \u003clinux/netlink.h\u003e\n #include \u003cnet/pkt_sched.h\u003e\n@@ -66,27 +67,25 @@ static netdev_tx_t rmnet_vnd_start_xmit(struct sk_buff *skb,\n \treturn NETDEV_TX_OK;\n }\n \n-static int rmnet_vnd_headroom(struct rmnet_port *port)\n+static int rmnet_vnd_headroom(u32 data_format)\n {\n \tu32 headroom;\n \n \theadroom = sizeof(struct rmnet_map_header);\n \n-\tif (port-\u003edata_format \u0026 RMNET_FLAGS_EGRESS_MAP_CKSUMV4)\n+\tif (data_format \u0026 RMNET_FLAGS_EGRESS_MAP_CKSUMV4)\n \t\theadroom += sizeof(struct rmnet_map_ul_csum_header);\n \n \treturn headroom;\n }\n \n-static int rmnet_vnd_change_mtu(struct net_device *rmnet_dev, int new_mtu)\n+static int rmnet_vnd_change_mtu_with_format(struct net_device *rmnet_dev,\n+\t\t\t\t\t int new_mtu, u32 data_format)\n {\n \tstruct rmnet_priv *priv = netdev_priv(rmnet_dev);\n-\tstruct rmnet_port *port;\n \tu32 headroom;\n \n-\tport = rmnet_get_port_rtnl(priv-\u003ereal_dev);\n-\n-\theadroom = rmnet_vnd_headroom(port);\n+\theadroom = rmnet_vnd_headroom(data_format);\n \n \tif (new_mtu \u003c 0 || new_mtu \u003e RMNET_MAX_PACKET_SIZE ||\n \t new_mtu \u003e (priv-\u003ereal_dev-\u003emtu - headroom))\n@@ -96,6 +95,17 @@ static int rmnet_vnd_change_mtu(struct net_device *rmnet_dev, int new_mtu)\n \treturn 0;\n }\n \n+static int rmnet_vnd_change_mtu(struct net_device *rmnet_dev, int new_mtu)\n+{\n+\tstruct rmnet_priv *priv = netdev_priv(rmnet_dev);\n+\tstruct rmnet_port *port;\n+\n+\tport = rmnet_get_port_rtnl(priv-\u003ereal_dev);\n+\n+\treturn rmnet_vnd_change_mtu_with_format(rmnet_dev, new_mtu,\n+\t\t\t\t\t\tREAD_ONCE(port-\u003edata_format));\n+}\n+\n static int rmnet_vnd_get_iflink(const struct net_device *dev)\n {\n \tstruct rmnet_priv *priv = netdev_priv(dev);\n@@ -132,7 +142,9 @@ static void rmnet_vnd_uninit(struct net_device *dev)\n static void rmnet_get_stats64(struct net_device *dev,\n \t\t\t struct rtnl_link_stats64 *s)\n {\n+\tstruct rmnet_priv_stats total_priv_stats = { };\n \tstruct rmnet_priv *priv = netdev_priv(dev);\n+\tstruct rmnet_priv_stats priv_snapshot;\n \tstruct rmnet_vnd_stats total_stats = { };\n \tstruct rmnet_pcpu_stats *pcpu_ptr;\n \tstruct rmnet_vnd_stats snapshot;\n@@ -144,6 +156,8 @@ static void rmnet_get_stats64(struct net_device *dev,\n \t\tdo {\n \t\t\tstart = u64_stats_fetch_begin(\u0026pcpu_ptr-\u003esyncp);\n \t\t\tsnapshot = pcpu_ptr-\u003estats;\t/* struct assignment */\n+\t\t\tu64_stats_copy(\u0026priv_snapshot, \u0026pcpu_ptr-\u003epriv_stats,\n+\t\t\t\t sizeof(priv_snapshot));\n \t\t} while (u64_stats_fetch_retry(\u0026pcpu_ptr-\u003esyncp, start));\n \n \t\ttotal_stats.rx_pkts += snapshot.rx_pkts;\n@@ -151,6 +165,7 @@ static void rmnet_get_stats64(struct net_device *dev,\n \t\ttotal_stats.tx_pkts += snapshot.tx_pkts;\n \t\ttotal_stats.tx_bytes += snapshot.tx_bytes;\n \t\ttotal_stats.tx_drops += snapshot.tx_drops;\n+\t\ttotal_priv_stats.rx_dropped += priv_snapshot.rx_dropped;\n \t}\n \n \ts-\u003erx_packets = total_stats.rx_pkts;\n@@ -158,8 +173,45 @@ static void rmnet_get_stats64(struct net_device *dev,\n \ts-\u003etx_packets = total_stats.tx_pkts;\n \ts-\u003etx_bytes = total_stats.tx_bytes;\n \ts-\u003etx_dropped = total_stats.tx_drops;\n+\ts-\u003erx_dropped = total_priv_stats.rx_dropped;\n }\n \n+/* Report standard network stack RX statistics. These are distinct from the\n+ * rmnet-specific coalescing diagnostics exposed through ethtool.\n+ */\n+static void rmnet_get_queue_stats_rx(struct net_device *dev, int idx,\n+\t\t\t\t struct netdev_queue_stats_rx *stats)\n+{\n+\tstruct rmnet_priv *priv = netdev_priv(dev);\n+\tstruct rmnet_priv_stats total_stats = { };\n+\tstruct rmnet_pcpu_stats *pcpu_ptr;\n+\tstruct rmnet_priv_stats snapshot;\n+\tunsigned int cpu, start;\n+\n+\tfor_each_possible_cpu(cpu) {\n+\t\tpcpu_ptr = per_cpu_ptr(priv-\u003epcpu_stats, cpu);\n+\n+\t\tdo {\n+\t\t\tstart = u64_stats_fetch_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tu64_stats_copy(\u0026snapshot, \u0026pcpu_ptr-\u003epriv_stats,\n+\t\t\t\t sizeof(snapshot));\n+\t\t} while (u64_stats_fetch_retry(\u0026pcpu_ptr-\u003esyncp, start));\n+\n+\t\ttotal_stats.rx_hw_gro_packets += snapshot.rx_hw_gro_packets;\n+\t\ttotal_stats.rx_hw_gro_wire_packets +=\n+\t\t\tsnapshot.rx_hw_gro_wire_packets;\n+\t\ttotal_stats.rx_alloc_fail += snapshot.rx_alloc_fail;\n+\t}\n+\n+\tstats-\u003ehw_gro_packets = total_stats.rx_hw_gro_packets;\n+\tstats-\u003ehw_gro_wire_packets = total_stats.rx_hw_gro_wire_packets;\n+\tstats-\u003ealloc_fail = total_stats.rx_alloc_fail;\n+}\n+\n+static const struct netdev_stat_ops rmnet_stat_ops = {\n+\t.get_queue_stats_rx = rmnet_get_queue_stats_rx,\n+};\n+\n static const struct net_device_ops rmnet_vnd_ops = {\n \t.ndo_start_xmit = rmnet_vnd_start_xmit,\n \t.ndo_change_mtu = rmnet_vnd_change_mtu,\n@@ -183,8 +235,34 @@ static const char rmnet_gstrings_stats[][ETH_GSTRING_LEN] = {\n \t\"Checksum skipped\",\n \t\"Checksum computed in software\",\n \t\"Checksum computed in hardware\",\n+\t/* DL coalescing */\n+\t\"Coal alloc packet drops\",\n+\t\"Coal frames received\",\n+\t\"Packets in coal frames\",\n+\t\"Coal header errors\",\n+\t\"Coal hdr pkt count errors\",\n+\t\"Coal bounds errors\",\n+\t\"Coal checksum errors\",\n+\t\"Coal packets dropped on csum err\",\n+\t\"Coal segments reconstructed\",\n+\t\"Coal invalid IP packet\",\n+\t\"Coal invalid transport\",\n+\t/* close reasons */\n+\t\"Coal closed: non-coal\",\n+\t\"Coal closed: IP miss\",\n+\t\"Coal closed: transport miss\",\n+\t\"Coal closed: hw NL limit\",\n+\t\"Coal closed: hw pkt limit\",\n+\t\"Coal closed: hw byte limit\",\n+\t\"Coal closed: hw time limit\",\n+\t\"Coal closed: hw evict\",\n+\t\"Coal closed: FIN/PSH\",\n };\n \n+static_assert(ARRAY_SIZE(rmnet_gstrings_stats) ==\n+\t (sizeof(struct rmnet_priv_stats) -\n+\t offsetof(struct rmnet_priv_stats, csum_ok)) / sizeof(u64));\n+\n static void rmnet_get_strings(struct net_device *dev, u32 stringset, u8 *buf)\n {\n \tswitch (stringset) {\n@@ -209,12 +287,62 @@ static void rmnet_get_ethtool_stats(struct net_device *dev,\n \t\t\t\t struct ethtool_stats *stats, u64 *data)\n {\n \tstruct rmnet_priv *priv = netdev_priv(dev);\n-\tstruct rmnet_priv_stats *st = \u0026priv-\u003estats;\n+\tstruct rmnet_priv_stats total_stats = { };\n+\tstruct rmnet_pcpu_stats *pcpu_ptr;\n+\tstruct rmnet_priv_stats snapshot;\n+\tunsigned int cpu, start;\n \n \tif (!data)\n \t\treturn;\n \n-\tmemcpy(data, st, ARRAY_SIZE(rmnet_gstrings_stats) * sizeof(u64));\n+\tfor_each_possible_cpu(cpu) {\n+\t\tpcpu_ptr = per_cpu_ptr(priv-\u003epcpu_stats, cpu);\n+\n+\t\tdo {\n+\t\t\tstart = u64_stats_fetch_begin(\u0026pcpu_ptr-\u003esyncp);\n+\t\t\tu64_stats_copy(\u0026snapshot, \u0026pcpu_ptr-\u003epriv_stats,\n+\t\t\t\t sizeof(snapshot));\n+\t\t} while (u64_stats_fetch_retry(\u0026pcpu_ptr-\u003esyncp, start));\n+\n+\t\ttotal_stats.csum_ok += snapshot.csum_ok;\n+\t\ttotal_stats.csum_ip4_header_bad += snapshot.csum_ip4_header_bad;\n+\t\ttotal_stats.csum_valid_unset += snapshot.csum_valid_unset;\n+\t\ttotal_stats.csum_validation_failed += snapshot.csum_validation_failed;\n+\t\ttotal_stats.csum_err_bad_buffer += snapshot.csum_err_bad_buffer;\n+\t\ttotal_stats.csum_err_invalid_ip_version +=\n+\t\t\tsnapshot.csum_err_invalid_ip_version;\n+\t\ttotal_stats.csum_err_invalid_transport +=\n+\t\t\tsnapshot.csum_err_invalid_transport;\n+\t\ttotal_stats.csum_fragmented_pkt += snapshot.csum_fragmented_pkt;\n+\t\ttotal_stats.csum_skipped += snapshot.csum_skipped;\n+\t\ttotal_stats.csum_sw += snapshot.csum_sw;\n+\t\ttotal_stats.csum_hw += snapshot.csum_hw;\n+\t\t/* Custom rmnet coalescing diagnostics follow. */\n+\t\ttotal_stats.coal_alloc_fail += snapshot.coal_alloc_fail;\n+\t\ttotal_stats.coal_rx += snapshot.coal_rx;\n+\t\ttotal_stats.coal_pkts += snapshot.coal_pkts;\n+\t\ttotal_stats.coal_hdr_err += snapshot.coal_hdr_err;\n+\t\ttotal_stats.coal_hdr_pkt_err += snapshot.coal_hdr_pkt_err;\n+\t\ttotal_stats.coal_bounds_err += snapshot.coal_bounds_err;\n+\t\ttotal_stats.coal_csum_err += snapshot.coal_csum_err;\n+\t\ttotal_stats.coal_csum_drop += snapshot.coal_csum_drop;\n+\t\ttotal_stats.coal_reconstruct += snapshot.coal_reconstruct;\n+\t\ttotal_stats.coal_ip_invalid += snapshot.coal_ip_invalid;\n+\t\ttotal_stats.coal_trans_invalid += snapshot.coal_trans_invalid;\n+\t\ttotal_stats.coal_close_non_coal += snapshot.coal_close_non_coal;\n+\t\ttotal_stats.coal_close_ip_miss += snapshot.coal_close_ip_miss;\n+\t\ttotal_stats.coal_close_trans_miss += snapshot.coal_close_trans_miss;\n+\t\ttotal_stats.coal_close_hw_nl += snapshot.coal_close_hw_nl;\n+\t\ttotal_stats.coal_close_hw_pkt += snapshot.coal_close_hw_pkt;\n+\t\ttotal_stats.coal_close_hw_byte += snapshot.coal_close_hw_byte;\n+\t\ttotal_stats.coal_close_hw_time += snapshot.coal_close_hw_time;\n+\t\ttotal_stats.coal_close_hw_evict += snapshot.coal_close_hw_evict;\n+\t\ttotal_stats.coal_close_coal += snapshot.coal_close_coal;\n+\t}\n+\n+\t/* The first four fields are reported through netdev queue statistics. */\n+\tmemcpy(data, \u0026total_stats.csum_ok,\n+\t sizeof(total_stats) - offsetof(struct rmnet_priv_stats, csum_ok));\n }\n \n static int rmnet_get_coalesce(struct net_device *dev,\n@@ -308,8 +436,7 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,\n \t\t struct rmnet_port *port,\n \t\t struct net_device *real_dev,\n \t\t struct rmnet_endpoint *ep,\n-\t\t struct netlink_ext_ack *extack)\n-\n+\t\t struct netlink_ext_ack *extack, u32 data_format)\n {\n \tstruct rmnet_priv *priv = netdev_priv(rmnet_dev);\n \tu32 headroom;\n@@ -323,12 +450,16 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,\n \trmnet_dev-\u003ehw_features = NETIF_F_RXCSUM;\n \trmnet_dev-\u003ehw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;\n \trmnet_dev-\u003ehw_features |= NETIF_F_SG;\n+\trmnet_dev-\u003ehw_features |= NETIF_F_GRO_HW;\n+\trmnet_dev-\u003estat_ops = \u0026rmnet_stat_ops;\n \n \tpriv-\u003ereal_dev = real_dev;\n \n-\theadroom = rmnet_vnd_headroom(port);\n+\theadroom = rmnet_vnd_headroom(data_format);\n \n-\tif (rmnet_vnd_change_mtu(rmnet_dev, real_dev-\u003emtu - headroom)) {\n+\tif (rmnet_vnd_change_mtu_with_format(rmnet_dev,\n+\t\t\t\t\t real_dev-\u003emtu - headroom,\n+\t\t\t\t\t data_format)) {\n \t\tNL_SET_ERR_MSG_MOD(extack, \"Invalid MTU on real dev\");\n \t\treturn -EINVAL;\n \t}\n@@ -375,17 +506,15 @@ int rmnet_vnd_do_flow_control(struct net_device *rmnet_dev, int enable)\n \treturn 0;\n }\n \n-int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev)\n+static int rmnet_vnd_validate_mtu(struct rmnet_port *port,\n+\t\t\t\t struct net_device *real_dev, u32 data_format)\n {\n \tstruct hlist_node *tmp_ep;\n \tstruct rmnet_endpoint *ep;\n-\tstruct rmnet_port *port;\n \tunsigned long bkt_ep;\n \tu32 headroom;\n \n-\tport = rmnet_get_port_rtnl(real_dev);\n-\n-\theadroom = rmnet_vnd_headroom(port);\n+\theadroom = rmnet_vnd_headroom(data_format);\n \n \thash_for_each_safe(port-\u003emuxed_ep, bkt_ep, tmp_ep, ep, hlnode) {\n \t\tif (ep-\u003eegress_dev-\u003emtu \u003e (real_dev-\u003emtu - headroom))\n@@ -395,23 +524,39 @@ int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev)\n \treturn 0;\n }\n \n+int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev)\n+{\n+\tstruct rmnet_port *port;\n+\n+\tport = rmnet_get_port_rtnl(real_dev);\n+\n+\treturn rmnet_vnd_validate_mtu(port, real_dev,\n+\t\t\t\t READ_ONCE(port-\u003edata_format));\n+}\n+\n int rmnet_vnd_update_dev_mtu(struct rmnet_port *port,\n-\t\t\t struct net_device *real_dev)\n+\t\t\t struct net_device *real_dev, u32 data_format)\n {\n \tstruct hlist_node *tmp_ep;\n \tstruct rmnet_endpoint *ep;\n \tunsigned long bkt_ep;\n \tu32 headroom;\n+\tint new_mtu;\n \n-\theadroom = rmnet_vnd_headroom(port);\n+\theadroom = rmnet_vnd_headroom(data_format);\n+\tif (real_dev-\u003emtu \u003c headroom)\n+\t\treturn -EINVAL;\n+\n+\tnew_mtu = real_dev-\u003emtu - headroom;\n+\tif (new_mtu \u003e RMNET_MAX_PACKET_SIZE)\n+\t\treturn -EINVAL;\n \n \thash_for_each_safe(port-\u003emuxed_ep, bkt_ep, tmp_ep, ep, hlnode) {\n-\t\tif (ep-\u003eegress_dev-\u003emtu \u003c= (real_dev-\u003emtu - headroom))\n+\t\tif (ep-\u003eegress_dev-\u003emtu \u003c= new_mtu)\n \t\t\tcontinue;\n \n-\t\tif (rmnet_vnd_change_mtu(ep-\u003eegress_dev,\n-\t\t\t\t\t real_dev-\u003emtu - headroom))\n-\t\t\treturn -1;\n+\t\t/* The target MTU was validated before updating any endpoint. */\n+\t\tWRITE_ONCE(ep-\u003eegress_dev-\u003emtu, new_mtu);\n \t}\n \n \treturn 0;\ndiff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h\nindex c2b2baf86894e..901ef36900ac3 100644\n--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h\n+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h\n@@ -12,7 +12,7 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,\n \t\t struct rmnet_port *port,\n \t\t struct net_device *real_dev,\n \t\t struct rmnet_endpoint *ep,\n-\t\t struct netlink_ext_ack *extack);\n+\t\t struct netlink_ext_ack *extack, u32 data_format);\n int rmnet_vnd_dellink(u8 id, struct rmnet_port *port,\n \t\t struct rmnet_endpoint *ep);\n void rmnet_vnd_rx_fixup(struct sk_buff *skb, struct net_device *dev);\n@@ -21,5 +21,5 @@ void rmnet_vnd_tx_fixup(struct sk_buff *skb, struct net_device *dev);\n void rmnet_vnd_setup(struct net_device *dev);\n int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev);\n int rmnet_vnd_update_dev_mtu(struct rmnet_port *port,\n-\t\t\t struct net_device *real_dev);\n+\t\t\t struct net_device *real_dev, u32 data_format);\n #endif /* _RMNET_VND_H_ */\ndiff --git a/include/linux/if_rmnet.h b/include/linux/if_rmnet.h\nindex c44bf6e80ecb4..5df4d417f3d2c 100644\n--- a/include/linux/if_rmnet.h\n+++ b/include/linux/if_rmnet.h\n@@ -70,5 +70,36 @@ struct rmnet_map_v5_csum_header {\n #define MAPV5_HDRINFO_HDR_TYPE_FMASK\tGENMASK(7, 1)\n #define MAPV5_CSUMINFO_VALID_FLAG\tBIT(7)\n \n+#define RMNET_MAP_HEADER_TYPE_COALESCING 1\n #define RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD 2\n+\n+/* MAPv5 coalescing header */\n+#define RMNET_MAP_V5_MAX_NLOS\t\t6\n+#define RMNET_MAP_V5_MAX_PACKETS\t48\n+\n+/* One Number-Length Object pair: per-NLO packet count and length. */\n+struct rmnet_map_v5_nl_pair {\n+\t__be16 pkt_len;\n+\tu8 csum_error_bitmap;\n+\tu8 num_packets;\n+} __aligned(1);\n+\n+/* MAPv5 coalescing header: describes up to RMNET_MAP_V5_MAX_NLOS NLOs.\n+ * The header immediately follows the MAP header in the frame and is\n+ * included in the MAP pkt_len field.\n+ */\n+struct rmnet_map_v5_coal_header {\n+\tu8 header_info;\t/* MAPV5_HDRINFO_NXT_HDR_FLAG, MAPV5_HDRINFO_HDR_TYPE_FMASK */\n+\tu8 coal_info;\t\t/* MAPV5_COALINFO_* */\n+\tu8 close_info;\t\t/* MAPV5_CLOSEINFO_* */\n+\tu8 veid_info;\t\t/* MAPV5_VEIDINFO_* */\n+\tstruct rmnet_map_v5_nl_pair nl_pairs[RMNET_MAP_V5_MAX_NLOS];\n+} __aligned(1);\n+\n+#define MAPV5_COALINFO_NUM_NLOS_FMASK\t\tGENMASK(6, 4)\n+#define MAPV5_COALINFO_CSUM_VALID_FLAG\t\tBIT(7)\n+#define MAPV5_CLOSEINFO_CLOSE_TYPE_FMASK\tGENMASK(3, 0)\n+#define MAPV5_CLOSEINFO_CLOSE_VALUE_FMASK\tGENMASK(7, 4)\n+#define MAPV5_VEIDINFO_VEID_FMASK\t\tGENMASK(3, 0)\n+\n #endif /* !(_LINUX_IF_RMNET_H_) */\ndiff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h\nindex 245b362045253..349fcddc6622f 100644\n--- a/include/uapi/linux/if_link.h\n+++ b/include/uapi/linux/if_link.h\n@@ -2022,6 +2022,7 @@ enum {\n #define RMNET_FLAGS_EGRESS_MAP_CKSUMV4 (1U \u003c\u003c 3)\n #define RMNET_FLAGS_INGRESS_MAP_CKSUMV5 (1U \u003c\u003c 4)\n #define RMNET_FLAGS_EGRESS_MAP_CKSUMV5 (1U \u003c\u003c 5)\n+#define RMNET_FLAGS_INGRESS_COALESCE (1U \u003c\u003c 6)\n \n enum {\n \tIFLA_RMNET_UNSPEC,\n"
} |
| 2/1 | 2026/10/08 01:20 | agent | patch-evaluator |
2mModel:core Args: null Results: {
"EnableConfigs": [
"NET_VENDOR_QUALCOMM",
"RMNET"
],
"FocusSymbols": [
"rmnet_map_process_next_hdr_packet",
"rmnet_map_segment_coal_skb",
"__rmnet_map_segment_coal_skb",
"rmnet_map_coal_validate_bounds",
"rmnet_map_data_check_coal_header",
"rmnet_map_coal_gro_fast_path",
"rmnet_vnd_update_dev_mtu",
"rmnet_newlink"
],
"Reasoning": "The patch adds MAPv5 downlink packet coalescing and de-aggregation support to Qualcomm's rmnet driver. RMNet is an rtnl virtual netlink device (kind \"rmnet\") that can attach to any underlying network interface (including virtual devices such as dummy or veth) without dedicated physical hardware. Ingress packets can be delivered from userspace through the base interface to exercise the new frame parsing, NLO validation, checksum verification, skb reallocation, and GSO segment construction logic. This complex network packet manipulation is fully reachable in virtualized fuzzing environments.",
"WorthFuzzing": true
}Instruction: You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.
IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.
================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.
- REACHABILITY IS THE PRIMARY GATE:
Fuzzing can only discover bugs in code that can actually execute in standard virtualized
environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
regardless of whether it adds assertions or complex logic.
- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
Patch authors routinely label changes as "cleanups", "refactorings", or state
"No functional change intended". Do NOT take these claims at face value.
Code refactorings that rearrange logic, introduce helper functions, or alter state management
in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
If reachable executable code is modified or refactored, it MUST be fuzzed.
- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
Even if the author believes the invariant always holds, fuzzing is essential to verify whether
an unusual sequence of operations can violate it.
================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:
- Non-kernel and non-executable changes:
* Modifications to Documentation/, comments, or spelling fixes.
* User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
that do not affect the compiled kernel image (vmlinux) or kernel modules.
* Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
that do not alter control flow or data structures.
* Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
* Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
* Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
physical PCI hot-unplug or manual sysfs driver unbinding.
* Code paths exclusive to architectures other than the target architecture.
================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
* Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
* Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
* Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
* Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).
================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:
- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
Do NOT list generic, ubiquitous functions called by almost every program in the corpus
(including, but not limited to: general memory allocators and deallocators, page fault
and trap handlers, or core synchronization primitives; this is not an exhaustive list).
Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
which severely dilutes fuzzing effort away from the actual changes.
- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
List functions that specifically implement the logic being added or altered, or direct API entrypoints
for the subsystem feature under review.
- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).
================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit 5f934836a3da604812716de3e50f9bc46f6de000
Author: syz-cluster <triage@syzkaller.com>
Date: Thu Oct 8 01:20:03 2026 +0000
syz-cluster: applied patch under review
diff --git a/Documentation/networking/device_drivers/cellular/qualcomm/rmnet.rst b/Documentation/networking/device_drivers/cellular/qualcomm/rmnet.rst
index 5aedbabb73827..52f92d2fba311 100644
--- a/Documentation/networking/device_drivers/cellular/qualcomm/rmnet.rst
+++ b/Documentation/networking/device_drivers/cellular/qualcomm/rmnet.rst
@@ -125,8 +125,8 @@ Command (1)/ Data (0) bit value is to indicate if the packet is a MAP command
or data packet. Command packet is used for transport level flow control. Data
packets are standard IP packets.
-Next header is used to indicate the presence of another header, currently is
-limited to checksum header.
+Next header is used to indicate the presence of another header, currently
+limited to the checksum and coalescing headers.
Padding is the number of bytes to be appended to the payload to
ensure 4 byte alignment.
@@ -150,11 +150,11 @@ Header Type is to indicate the type of header, this usually is set to CHECKSUM
Header types
-= ===============
+= ======================
0 Reserved
-1 Reserved
+1 coalescing header
2 checksum header
-= ===============
+= ======================
Checksum Valid is to indicate whether the header checksum is valid. Value of 1
implies that checksum is calculated on this packet and is valid, value of 0
@@ -162,8 +162,109 @@ indicates that the calculated packet checksum is invalid.
Reserved bits must be zero when sent and ignored when received.
-e. MAP packet v1/v5 (command specific)
---------------------------------------
+e. Coalescing header v5
+------------------------
+
+Hardware can coalesce multiple same-flow IP packets into a single MAP frame
+to reduce per-packet overhead at high data rates. Packets are grouped into
+NLOs, with all packets in each NLO having the same length. The coalescing
+header (header type 1) describes the coalesced content.
+
+Packet format::
+
+ Bit 0 - 6 7 8 9-11 12-15
+ Function Header Type Next Header CSUM valid Num NLOs (reserved)
+
+ Bit 16-19 20-23
+ Function Close value Close type
+
+ Bit 24-27 28-31
+ Function (reserved) VEID
+
+ Bit 32 - 47 48 - 55 56 - 63
+ Function Packet length CSUM error bitmap Num packets (NLO 0)
+
+ ... (up to 6 NLO entries total, same 32-bit format per entry)
+
+Header Type is set to 1 (coalescing).
+
+The MAP header ``pkt_len`` includes the coalescing header, coalesced packet
+data, and any MAP padding.
+
+Num NLOs (Number-Length Objects) is the count of active NLO entries
+(1 – 6). Each NLO describes a group of consecutive coalesced packets
+that all share the same IP packet length.
+
+Num NLOs identifies the active prefix of the six NLO slots. The header
+always contains all six slots and remains 28 bytes long regardless of Num
+NLOs. A slot with ``num_packets == 0`` ends the active NLO prefix. The
+full coalescing header is included in the MAP header's ``pkt_len``.
+
+Some hardware may report Num NLOs incorrectly. For compatibility, receivers
+should derive the active prefix from ``num_packets`` when needed. This
+requires unused slots to have ``num_packets == 0``.
+
+CSUM valid (bit 8) is a frame-level indication that the hardware checksum is
+valid for all packets in the frame. It is distinct from the per-packet CSUM
+error bitmap in each NLO entry.
+
+For a single-NLO, single-packet frame, CSUM valid must not be trusted when
+the close reason is a FIN/PSH close, a packet limit, a byte limit, or a time
+limit. In these cases, the rmnet driver treats the packet checksum as
+unverified and lets the network stack validate it instead of relying on the
+coalescing checksum indications.
+IPv4 UDP packets with a zero checksum remain valid because that checksum is
+optional.
+
+Close type and close value encode the hardware reason that coalescing
+was terminated for this frame:
+
+Close type values:
+
+= ==============================
+0 non-coalesced (single packet)
+1 IP flow miss
+2 transport flow miss
+3 hardware limit (see value)
+4 coalescing closed (FIN/PSH)
+= ==============================
+
+Close value (used when close type is 3):
+
+= ==================
+0 NL limit reached
+1 packet limit
+2 byte limit
+3 time limit
+4 eviction
+= ==================
+
+VEID is the virtual endpoint ID of the originating flow.
+
+Each NLO entry::
+
+ Bit 0 - 15 16 - 23 24 - 31
+ Function Pkt length CSUM error bitmap Num packets
+
+Pkt length is the full IP packet length, including the IP header, transport
+header, and payload, for every packet in this NLO group. The IP and transport
+headers are present once in the coalesced frame and are not repeated for each
+packet.
+
+CSUM error bitmap is one 48-bit stream formed by concatenating the
+``csum_error_bitmap`` bytes from all six NLO slots in slot order. Packet 0
+corresponds to bit 0 of slot 0's bitmap byte, and bits are consumed from
+least significant bit to most significant bit. The bit stream is indexed by
+the packet's absolute position in the frame and does not restart at an NLO
+boundary. If an NLO contains more than eight packets, its error bits
+continue into the bitmap byte of the following slot. Bitmap bytes in slots
+after the active NLO prefix may therefore contain continuation bits and must
+not be ignored.
+
+Num packets is the count of coalesced packets described by this NLO.
+
+f. MAP packet v1/v5 (command specific)
+---------------------------------------
Packet format::
@@ -187,7 +288,7 @@ Command types
3 is for error during processing of commands
= ==========================================
-f. Aggregation
+g. Aggregation
--------------
Aggregation is multiple MAP packets (can be data or command) delivered to
@@ -208,3 +309,39 @@ rmnet userspace configuration is done through netlink using iproute2
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/
The driver uses rtnl_link_ops for communication.
+
+The data format flags controlling the ingress and egress processing
+pipeline are set via the ``IFLA_RMNET_FLAGS`` attribute
+(``struct ifla_rmnet_flags``).
+
+Relevant ingress flags:
+
+``RMNET_FLAGS_INGRESS_DEAGGREGATION``
+ Enable MAP frame de-aggregation.
+
+``RMNET_FLAGS_INGRESS_MAP_CKSUMV4``
+ Enable MAPv4 downlink checksum offload.
+
+``RMNET_FLAGS_INGRESS_MAP_CKSUMV5``
+ Enable MAPv5 downlink checksum offload (header type 2).
+
+``RMNET_FLAGS_INGRESS_COALESCE``
+ Enable MAPv5 downlink hardware coalescing (header type 1).
+ This flag requires ``RMNET_FLAGS_INGRESS_MAP_CKSUMV5``. MAPv4 and
+ MAPv5 checksum flags cannot be enabled together in either direction.
+ A direction may leave checksum offload disabled. Invalid combinations
+ are rejected.
+ When RX checksum offload and ``rx-gro-hw`` are enabled, valid
+ multi-packet coalesced frames can be delivered as batched GSO SKBs.
+ Otherwise, multi-packet coalesced frames are rejected. A coalesced frame
+ containing one packet is delivered as a normal non-GSO skb. IP options,
+ IPv6 extension headers, and zero-payload packets can also prevent GSO
+ processing for a frame.
+
+Relevant egress flags:
+
+``RMNET_FLAGS_EGRESS_MAP_CKSUMV4``
+ Enable MAPv4 uplink checksum offload.
+
+``RMNET_FLAGS_EGRESS_MAP_CKSUMV5``
+ Enable MAPv5 uplink checksum offload.
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
index 61b04c6c0390e..ec882ad371ab7 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
@@ -26,6 +26,31 @@ static int rmnet_is_real_dev_registered(const struct net_device *real_dev)
return rcu_access_pointer(real_dev->rx_handler) == rmnet_rx_handler;
}
+/* Only three MAP configurations are supported: MAPv1 (no checksum
+ * offload), MAPv4 (v4 checksum offload) and MAPv5 (v5 checksum
+ * offload). MAP command support is orthogonal and permitted with any
+ * of the three. Checksum offload versions are selected independently
+ * for ingress and egress, but only one version may be enabled across
+ * the device. Mixing v4 and v5 checksum flags is not supported. DL
+ * packet coalescing additionally requires a MAPv5 configuration.
+ */
+static bool rmnet_config_data_format_valid(u32 data_format)
+{
+ u32 v4_mask = RMNET_FLAGS_INGRESS_MAP_CKSUMV4 |
+ RMNET_FLAGS_EGRESS_MAP_CKSUMV4;
+ u32 v5_mask = RMNET_FLAGS_INGRESS_MAP_CKSUMV5 |
+ RMNET_FLAGS_EGRESS_MAP_CKSUMV5;
+
+ if ((data_format & v4_mask) && (data_format & v5_mask))
+ return false;
+
+ if ((data_format & RMNET_FLAGS_INGRESS_COALESCE) &&
+ !(data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV5))
+ return false;
+
+ return true;
+}
+
/* Needs rtnl lock */
struct rmnet_port*
rmnet_get_port_rtnl(const struct net_device *real_dev)
@@ -143,6 +168,20 @@ static int rmnet_newlink(struct net_device *dev,
return -ENODEV;
}
+ if (data[IFLA_RMNET_FLAGS]) {
+ struct ifla_rmnet_flags *flags;
+
+ flags = nla_data(data[IFLA_RMNET_FLAGS]);
+ data_format &= ~flags->mask;
+ data_format |= flags->flags & flags->mask;
+ }
+
+ if (!rmnet_config_data_format_valid(data_format)) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "unsupported MAP checksum flag combination");
+ return -EINVAL;
+ }
+
ep = kzalloc_obj(*ep);
if (!ep)
return -ENOMEM;
@@ -154,7 +193,8 @@ static int rmnet_newlink(struct net_device *dev,
goto err0;
port = rmnet_get_port_rtnl(real_dev);
- err = rmnet_vnd_newlink(mux_id, dev, port, real_dev, ep, extack);
+ err = rmnet_vnd_newlink(mux_id, dev, port, real_dev, ep, extack,
+ data_format);
if (err)
goto err1;
@@ -162,24 +202,23 @@ static int rmnet_newlink(struct net_device *dev,
if (err < 0)
goto err2;
+ /* Update existing MTUs before publishing the shared data format. */
+ err = rmnet_vnd_update_dev_mtu(port, real_dev, data_format);
+ if (err)
+ goto err3;
+
port->rmnet_mode = mode;
port->rmnet_dev = dev;
hlist_add_head_rcu(&ep->hlnode, &port->muxed_ep[mux_id]);
- if (data[IFLA_RMNET_FLAGS]) {
- struct ifla_rmnet_flags *flags;
-
- flags = nla_data(data[IFLA_RMNET_FLAGS]);
- data_format &= ~flags->mask;
- data_format |= flags->flags & flags->mask;
- }
-
netdev_dbg(dev, "data format [0x%08X]\n", data_format);
WRITE_ONCE(port->data_format, data_format);
return 0;
+err3:
+ netdev_upper_dev_unlink(real_dev, dev);
err2:
unregister_netdevice(dev);
rmnet_vnd_dellink(mux_id, port, ep);
@@ -301,9 +340,13 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],
struct netlink_ext_ack *extack)
{
struct rmnet_priv *priv = netdev_priv(dev);
+ struct ifla_rmnet_flags *flags;
struct net_device *real_dev;
struct rmnet_port *port;
+ u32 old_data_format;
+ u32 data_format;
u16 mux_id;
+ int err;
if (!dev)
return -ENODEV;
@@ -320,6 +363,19 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],
port = rmnet_get_port_rtnl(real_dev);
+ if (data[IFLA_RMNET_FLAGS]) {
+ old_data_format = READ_ONCE(port->data_format);
+ flags = nla_data(data[IFLA_RMNET_FLAGS]);
+ data_format = old_data_format & ~flags->mask;
+ data_format |= flags->flags & flags->mask;
+
+ if (!rmnet_config_data_format_valid(data_format)) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "unsupported MAP checksum flag combination");
+ return -EINVAL;
+ }
+ }
+
if (data[IFLA_RMNET_MUX_ID]) {
mux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]);
@@ -346,21 +402,13 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],
}
if (data[IFLA_RMNET_FLAGS]) {
- struct ifla_rmnet_flags *flags;
- u32 old_data_format;
- u32 data_format;
-
- old_data_format = port->data_format;
- flags = nla_data(data[IFLA_RMNET_FLAGS]);
- data_format = old_data_format & ~flags->mask;
- data_format |= flags->flags & flags->mask;
- WRITE_ONCE(port->data_format, data_format);
-
- if (rmnet_vnd_update_dev_mtu(port, real_dev)) {
- WRITE_ONCE(port->data_format, old_data_format);
+ err = rmnet_vnd_update_dev_mtu(port, real_dev, data_format);
+ if (err) {
NL_SET_ERR_MSG_MOD(extack, "Invalid MTU on real dev");
- return -EINVAL;
+ return err;
}
+
+ WRITE_ONCE(port->data_format, data_format);
}
return 0;
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h
index 5adda0323dda7..c71587c843e47 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h
@@ -63,12 +63,14 @@ struct rmnet_vnd_stats {
u32 tx_drops;
};
-struct rmnet_pcpu_stats {
- struct rmnet_vnd_stats stats;
- struct u64_stats_sync syncp;
-};
-
struct rmnet_priv_stats {
+ /* Network stack RX statistics for all rmnet receive paths */
+ u64 rx_hw_gro_packets;
+ u64 rx_hw_gro_wire_packets;
+ u64 rx_alloc_fail;
+ u64 rx_dropped;
+
+ /* Custom diagnostics for the coalescing receive path */
u64 csum_ok;
u64 csum_ip4_header_bad;
u64 csum_valid_unset;
@@ -80,6 +82,77 @@ struct rmnet_priv_stats {
u64 csum_skipped;
u64 csum_sw;
u64 csum_hw;
+ /* Coalescing-only counters. Some are subsets of the standard counters. */
+ u64 coal_alloc_fail;
+ u64 coal_rx;
+ u64 coal_pkts;
+ u64 coal_hdr_err;
+ u64 coal_hdr_pkt_err;
+ u64 coal_bounds_err;
+ u64 coal_csum_err;
+ u64 coal_csum_drop;
+ u64 coal_reconstruct;
+ u64 coal_ip_invalid;
+ u64 coal_trans_invalid;
+ /* close-reason sub-counters */
+ u64 coal_close_non_coal;
+ u64 coal_close_ip_miss;
+ u64 coal_close_trans_miss;
+ u64 coal_close_hw_nl;
+ u64 coal_close_hw_pkt;
+ u64 coal_close_hw_byte;
+ u64 coal_close_hw_time;
+ u64 coal_close_hw_evict;
+ u64 coal_close_coal;
+};
+
+struct rmnet_pcpu_priv_stats {
+ /* Network stack RX statistics for all rmnet receive paths */
+ u64_stats_t rx_hw_gro_packets;
+ u64_stats_t rx_hw_gro_wire_packets;
+ u64_stats_t rx_alloc_fail;
+ u64_stats_t rx_dropped;
+
+ /* Custom diagnostics for the coalescing receive path */
+ u64_stats_t csum_ok;
+ u64_stats_t csum_ip4_header_bad;
+ u64_stats_t csum_valid_unset;
+ u64_stats_t csum_validation_failed;
+ u64_stats_t csum_err_bad_buffer;
+ u64_stats_t csum_err_invalid_ip_version;
+ u64_stats_t csum_err_invalid_transport;
+ u64_stats_t csum_fragmented_pkt;
+ u64_stats_t csum_skipped;
+ u64_stats_t csum_sw;
+ u64_stats_t csum_hw;
+ /* Coalescing-only counters. Some are subsets of the standard counters. */
+ u64_stats_t coal_alloc_fail;
+ u64_stats_t coal_rx;
+ u64_stats_t coal_pkts;
+ u64_stats_t coal_hdr_err;
+ u64_stats_t coal_hdr_pkt_err;
+ u64_stats_t coal_bounds_err;
+ u64_stats_t coal_csum_err;
+ u64_stats_t coal_csum_drop;
+ u64_stats_t coal_reconstruct;
+ u64_stats_t coal_ip_invalid;
+ u64_stats_t coal_trans_invalid;
+ /* close-reason sub-counters */
+ u64_stats_t coal_close_non_coal;
+ u64_stats_t coal_close_ip_miss;
+ u64_stats_t coal_close_trans_miss;
+ u64_stats_t coal_close_hw_nl;
+ u64_stats_t coal_close_hw_pkt;
+ u64_stats_t coal_close_hw_byte;
+ u64_stats_t coal_close_hw_time;
+ u64_stats_t coal_close_hw_evict;
+ u64_stats_t coal_close_coal;
+};
+
+struct rmnet_pcpu_stats {
+ struct rmnet_vnd_stats stats;
+ struct rmnet_pcpu_priv_stats priv_stats;
+ struct u64_stats_sync syncp;
};
struct rmnet_priv {
@@ -87,7 +160,6 @@ struct rmnet_priv {
struct net_device *real_dev;
struct rmnet_pcpu_stats __percpu *pcpu_stats;
struct gro_cells gro_cells;
- struct rmnet_priv_stats stats;
};
struct rmnet_port *rmnet_get_port_rcu(const struct net_device *real_dev);
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c
index aa5523f4618eb..bb867ceb01c1c 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c
@@ -50,6 +50,16 @@ rmnet_deliver_skb(struct sk_buff *skb)
gro_cells_receive(&priv->gro_cells, skb);
}
+static void rmnet_deliver_skb_list(struct sk_buff_head *head)
+{
+ struct sk_buff *skb;
+
+ while ((skb = __skb_dequeue(head))) {
+ rmnet_set_skb_proto(skb);
+ rmnet_deliver_skb(skb);
+ }
+}
+
/* MAP handler */
static void
@@ -59,6 +69,7 @@ __rmnet_map_ingress_handler(struct sk_buff *skb,
{
struct rmnet_map_header *map_header = (void *)skb->data;
struct rmnet_endpoint *ep;
+ struct sk_buff_head list;
u16 len, pad;
u8 mux_id;
@@ -83,12 +94,13 @@ __rmnet_map_ingress_handler(struct sk_buff *skb,
skb->dev = ep->egress_dev;
- if ((data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV5) &&
+ __skb_queue_head_init(&list);
+
+ if ((data_format &
+ (RMNET_FLAGS_INGRESS_MAP_CKSUMV5 | RMNET_FLAGS_INGRESS_COALESCE)) &&
(map_header->flags & MAP_NEXT_HEADER_FLAG)) {
- if (rmnet_map_process_next_hdr_packet(skb, len))
+ if (rmnet_map_process_next_hdr_packet(skb, &list, len, data_format))
goto free_skb;
- skb_pull(skb, sizeof(*map_header));
- rmnet_set_skb_proto(skb);
} else {
/* Subtract MAP header */
skb_pull(skb, sizeof(*map_header));
@@ -96,10 +108,11 @@ __rmnet_map_ingress_handler(struct sk_buff *skb,
if (data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV4 &&
!rmnet_map_checksum_downlink_packet(skb, len + pad))
skb->ip_summed = CHECKSUM_UNNECESSARY;
+ skb_trim(skb, len);
+ __skb_queue_tail(&list, skb);
}
- skb_trim(skb, len);
- rmnet_deliver_skb(skb);
+ rmnet_deliver_skb_list(&list);
return;
free_skb:
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h
index 0977e495f5915..77ddac6023c01 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h
@@ -6,6 +6,22 @@
#define _RMNET_MAP_H_
#include <linux/if_rmnet.h>
+enum rmnet_map_v5_close_type {
+ RMNET_MAP_COAL_CLOSE_NON_COAL,
+ RMNET_MAP_COAL_CLOSE_IP_MISS,
+ RMNET_MAP_COAL_CLOSE_TRANS_MISS,
+ RMNET_MAP_COAL_CLOSE_HW,
+ RMNET_MAP_COAL_CLOSE_COAL,
+};
+
+enum rmnet_map_v5_close_value {
+ RMNET_MAP_COAL_CLOSE_HW_NL,
+ RMNET_MAP_COAL_CLOSE_HW_PKT,
+ RMNET_MAP_COAL_CLOSE_HW_BYTE,
+ RMNET_MAP_COAL_CLOSE_HW_TIME,
+ RMNET_MAP_COAL_CLOSE_HW_EVICT,
+};
+
struct rmnet_map_control_command {
u8 command_name;
u8 cmd_type:2;
@@ -53,7 +69,9 @@ void rmnet_map_checksum_uplink_packet(struct sk_buff *skb,
struct rmnet_port *port,
struct net_device *orig_dev,
int csum_type);
-int rmnet_map_process_next_hdr_packet(struct sk_buff *skb, u16 len);
+int rmnet_map_process_next_hdr_packet(struct sk_buff *skb,
+ struct sk_buff_head *list,
+ u16 len, u32 data_format);
unsigned int rmnet_map_tx_aggregate(struct sk_buff *skb, struct rmnet_port *port,
struct net_device *orig_dev);
void rmnet_map_tx_aggregate_init(struct rmnet_port *port);
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
index 39d6d084e73f0..74d64b7066e2b 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
@@ -7,7 +7,11 @@
#include <linux/netdevice.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
+#include <linux/tcp.h>
+#include <linux/udp.h>
+#include <net/ip.h>
#include <net/ip6_checksum.h>
+#include <net/ipv6.h>
#include <linux/bitfield.h>
#include "rmnet_config.h"
#include "rmnet_map.h"
@@ -17,6 +21,19 @@
#define RMNET_MAP_DEAGGR_SPACING 64
#define RMNET_MAP_DEAGGR_HEADROOM (RMNET_MAP_DEAGGR_SPACING / 2)
+struct rmnet_map_coal_metadata {
+ void *ip_header;
+ void *trans_header;
+ u16 ip_len;
+ u16 trans_len;
+ u16 data_offset;
+ u16 data_len;
+ u8 ip_proto;
+ u8 trans_proto;
+ u8 pkt_count;
+ bool zero_csum;
+};
+
static __sum16 *rmnet_map_get_csum_field(unsigned char protocol,
const void *txporthdr)
{
@@ -36,34 +53,45 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb,
{
struct iphdr *ip4h = (struct iphdr *)skb->data;
void *txporthdr = skb->data + ip4h->ihl * 4;
+ struct rmnet_pcpu_stats *pcpu_ptr;
__sum16 *csum_field, pseudo_csum;
__sum16 ip_payload_csum;
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
+
/* Computing the checksum over just the IPv4 header--including its
* checksum field--should yield 0. If it doesn't, the IP header
* is bad, so return an error and let the IP layer drop it.
*/
if (ip_fast_csum(ip4h, ip4h->ihl)) {
- priv->stats.csum_ip4_header_bad++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_ip4_header_bad);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return -EINVAL;
}
/* We don't support checksum offload on IPv4 fragments */
if (ip_is_fragment(ip4h)) {
- priv->stats.csum_fragmented_pkt++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_fragmented_pkt);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return -EOPNOTSUPP;
}
/* Checksum offload is only supported for UDP and TCP protocols */
csum_field = rmnet_map_get_csum_field(ip4h->protocol, txporthdr);
if (!csum_field) {
- priv->stats.csum_err_invalid_transport++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_err_invalid_transport);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return -EPROTONOSUPPORT;
}
/* RFC 768: UDP checksum is optional for IPv4, and is 0 if unused */
if (!*csum_field && ip4h->protocol == IPPROTO_UDP) {
- priv->stats.csum_skipped++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_skipped);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return 0;
}
@@ -96,11 +124,15 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb,
/* The cast is required to ensure only the low 16 bits are examined */
if (ip_payload_csum != (__sum16)~pseudo_csum) {
- priv->stats.csum_validation_failed++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_validation_failed);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return -EINVAL;
}
- priv->stats.csum_ok++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_ok);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return 0;
}
@@ -112,16 +144,21 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb,
{
struct ipv6hdr *ip6h = (struct ipv6hdr *)skb->data;
void *txporthdr = skb->data + sizeof(*ip6h);
+ struct rmnet_pcpu_stats *pcpu_ptr;
__sum16 *csum_field, pseudo_csum;
__sum16 ip6_payload_csum;
__be16 ip_header_csum;
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
+
/* Checksum offload is only supported for UDP and TCP protocols;
* the packet cannot include any IPv6 extension headers
*/
csum_field = rmnet_map_get_csum_field(ip6h->nexthdr, txporthdr);
if (!csum_field) {
- priv->stats.csum_err_invalid_transport++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_err_invalid_transport);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return -EPROTONOSUPPORT;
}
@@ -147,11 +184,15 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb,
* examined.
*/
if (ip6_payload_csum != (__sum16)~pseudo_csum) {
- priv->stats.csum_validation_failed++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_validation_failed);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return -EINVAL;
}
- priv->stats.csum_ok++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_ok);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return 0;
}
#else
@@ -246,6 +287,9 @@ static void rmnet_map_v5_checksum_uplink_packet(struct sk_buff *skb,
{
struct rmnet_priv *priv = netdev_priv(orig_dev);
struct rmnet_map_v5_csum_header *ul_header;
+ struct rmnet_pcpu_stats *pcpu_ptr;
+
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
ul_header = skb_push(skb, sizeof(*ul_header));
memset(ul_header, 0, sizeof(*ul_header));
@@ -270,7 +314,9 @@ static void rmnet_map_v5_checksum_uplink_packet(struct sk_buff *skb,
proto = ((struct ipv6hdr *)iph)->nexthdr;
trans = iph + ip_len;
} else {
- priv->stats.csum_err_invalid_ip_version++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_err_invalid_ip_version);
+ u64_stats_update_end(&pcpu_ptr->syncp);
goto sw_csum;
}
@@ -279,13 +325,17 @@ static void rmnet_map_v5_checksum_uplink_packet(struct sk_buff *skb,
skb->ip_summed = CHECKSUM_NONE;
/* Ask for checksum offloading */
ul_header->csum_info |= MAPV5_CSUMINFO_VALID_FLAG;
- priv->stats.csum_hw++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_hw);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return;
}
}
sw_csum:
- priv->stats.csum_sw++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_sw);
+ u64_stats_update_end(&pcpu_ptr->syncp);
}
/* Adds MAP header to front of skb->data
@@ -337,8 +387,8 @@ u32 rmnet_map_validate_packet_len(struct sk_buff *skb, u32 data_format)
{
struct rmnet_map_v5_csum_header *next_hdr = NULL;
struct rmnet_map_header *maph;
- void *data = skb->data;
u32 packet_len;
+ u8 hdr_type;
if (skb->len < sizeof(*maph))
return 0;
@@ -353,24 +403,28 @@ u32 rmnet_map_validate_packet_len(struct sk_buff *skb, u32 data_format)
if (data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV4) {
packet_len += sizeof(struct rmnet_map_dl_csum_trailer);
- } else if ((data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV5) &&
+ } else if ((data_format &
+ (RMNET_FLAGS_INGRESS_MAP_CKSUMV5 | RMNET_FLAGS_INGRESS_COALESCE)) &&
!(maph->flags & MAP_CMD_FLAG)) {
- /* Mapv5 data pkt without csum hdr is invalid */
if (!(maph->flags & MAP_NEXT_HEADER_FLAG))
return 0;
- packet_len += sizeof(*next_hdr);
- next_hdr = data + sizeof(*maph);
+ if (skb->len < sizeof(*maph) + sizeof(*next_hdr))
+ return 0;
+
+ next_hdr = (struct rmnet_map_v5_csum_header *)(skb->data + sizeof(*maph));
+ hdr_type = u8_get_bits(next_hdr->header_info,
+ MAPV5_HDRINFO_HDR_TYPE_FMASK);
+
+ if (hdr_type == RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD)
+ packet_len += sizeof(*next_hdr);
+ else if (hdr_type != RMNET_MAP_HEADER_TYPE_COALESCING)
+ return 0;
}
if (skb->len < packet_len)
return 0;
- if (next_hdr &&
- u8_get_bits(next_hdr->header_info, MAPV5_HDRINFO_HDR_TYPE_FMASK) !=
- RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD)
- return 0;
-
return packet_len;
}
@@ -413,16 +467,23 @@ int rmnet_map_checksum_downlink_packet(struct sk_buff *skb, u16 len)
{
struct rmnet_priv *priv = netdev_priv(skb->dev);
struct rmnet_map_dl_csum_trailer *csum_trailer;
+ struct rmnet_pcpu_stats *pcpu_ptr;
+
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
if (unlikely(!(skb->dev->features & NETIF_F_RXCSUM))) {
- priv->stats.csum_sw++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_sw);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return -EOPNOTSUPP;
}
csum_trailer = (struct rmnet_map_dl_csum_trailer *)(skb->data + len);
if (!(csum_trailer->flags & MAP_CSUM_DL_VALID_FLAG)) {
- priv->stats.csum_valid_unset++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_valid_unset);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return -EINVAL;
}
@@ -432,7 +493,9 @@ int rmnet_map_checksum_downlink_packet(struct sk_buff *skb, u16 len)
if (IS_ENABLED(CONFIG_IPV6) && skb->protocol == htons(ETH_P_IPV6))
return rmnet_map_ipv6_dl_csum_trailer(skb, csum_trailer, priv);
- priv->stats.csum_err_invalid_ip_version++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_err_invalid_ip_version);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return -EPROTONOSUPPORT;
}
@@ -442,8 +505,11 @@ static void rmnet_map_v4_checksum_uplink_packet(struct sk_buff *skb,
{
struct rmnet_priv *priv = netdev_priv(orig_dev);
struct rmnet_map_ul_csum_header *ul_header;
+ struct rmnet_pcpu_stats *pcpu_ptr;
void *iphdr;
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
+
ul_header = (struct rmnet_map_ul_csum_header *)
skb_push(skb, sizeof(struct rmnet_map_ul_csum_header));
@@ -459,22 +525,30 @@ static void rmnet_map_v4_checksum_uplink_packet(struct sk_buff *skb,
if (skb->protocol == htons(ETH_P_IP)) {
rmnet_map_ipv4_ul_csum_header(iphdr, ul_header, skb);
- priv->stats.csum_hw++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_hw);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return;
}
if (IS_ENABLED(CONFIG_IPV6) && skb->protocol == htons(ETH_P_IPV6)) {
rmnet_map_ipv6_ul_csum_header(iphdr, ul_header, skb);
- priv->stats.csum_hw++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_hw);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return;
}
- priv->stats.csum_err_invalid_ip_version++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_err_invalid_ip_version);
+ u64_stats_update_end(&pcpu_ptr->syncp);
sw_csum:
memset(ul_header, 0, sizeof(*ul_header));
- priv->stats.csum_sw++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_sw);
+ u64_stats_update_end(&pcpu_ptr->syncp);
}
/* Generates UL checksum meta info header for IPv4 and IPv6 over TCP and UDP
@@ -497,34 +571,847 @@ void rmnet_map_checksum_uplink_packet(struct sk_buff *skb,
}
}
-/* Process a MAPv5 packet header */
-int rmnet_map_process_next_hdr_packet(struct sk_buff *skb,
- u16 len)
+static struct rmnet_map_v5_csum_header *
+rmnet_map_get_next_hdr(struct sk_buff *skb)
{
- struct rmnet_priv *priv = netdev_priv(skb->dev);
- struct rmnet_map_v5_csum_header *next_hdr;
- u8 nexthdr_type;
+ return (struct rmnet_map_v5_csum_header *)(skb->data +
+ sizeof(struct rmnet_map_header));
+}
+
+static u8 rmnet_map_get_next_hdr_type(struct sk_buff *skb)
+{
+ struct rmnet_map_v5_csum_header *hdr = rmnet_map_get_next_hdr(skb);
+
+ return u8_get_bits(hdr->header_info, MAPV5_HDRINFO_HDR_TYPE_FMASK);
+}
+
+static bool rmnet_map_get_csum_valid(struct sk_buff *skb)
+{
+ struct rmnet_map_v5_csum_header *hdr = rmnet_map_get_next_hdr(skb);
- next_hdr = (struct rmnet_map_v5_csum_header *)(skb->data +
- sizeof(struct rmnet_map_header));
+ return !!(hdr->csum_info & MAPV5_CSUMINFO_VALID_FLAG);
+}
+
+/* Stamp GSO metadata so the network stack can segment a coalesced SKB. */
+static void rmnet_map_gso_stamp(struct sk_buff *skb,
+ struct rmnet_map_coal_metadata *coal_meta)
+{
+ struct skb_shared_info *shinfo = skb_shinfo(skb);
- nexthdr_type = u8_get_bits(next_hdr->header_info,
- MAPV5_HDRINFO_HDR_TYPE_FMASK);
+ if (coal_meta->trans_proto == IPPROTO_TCP)
+ shinfo->gso_type = (coal_meta->ip_proto == 4) ?
+ SKB_GSO_TCPV4 : SKB_GSO_TCPV6;
+ else
+ shinfo->gso_type = SKB_GSO_UDP_L4;
- if (nexthdr_type != RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD)
+ shinfo->gso_size = coal_meta->data_len;
+ shinfo->gso_segs = coal_meta->pkt_count;
+}
+
+/* Set the transport checksum to the pseudo-header checksum and request
+ * partial checksum offload, letting the NIC or stack finish it.
+ */
+static void rmnet_map_partial_csum(struct sk_buff *skb,
+ struct rmnet_map_coal_metadata *coal_meta)
+{
+ u16 pkt_len = skb->len - coal_meta->ip_len;
+ unsigned char *data = skb->data;
+ __sum16 pseudo;
+
+ if (coal_meta->ip_proto == 4) {
+ struct iphdr *iph = (struct iphdr *)data;
+
+ pseudo = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
+ pkt_len, coal_meta->trans_proto, 0);
+ } else {
+ struct ipv6hdr *ip6h = (struct ipv6hdr *)data;
+
+ pseudo = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
+ pkt_len, coal_meta->trans_proto, 0);
+ }
+
+ if (coal_meta->trans_proto == IPPROTO_TCP) {
+ struct tcphdr *tp = (struct tcphdr *)(data + coal_meta->ip_len);
+
+ tp->check = pseudo;
+ skb->csum_offset = offsetof(struct tcphdr, check);
+ } else {
+ struct udphdr *up = (struct udphdr *)(data + coal_meta->ip_len);
+
+ up->check = pseudo;
+ skb->csum_offset = offsetof(struct udphdr, check);
+ }
+
+ skb->ip_summed = CHECKSUM_PARTIAL;
+ skb->csum_start = skb->data + coal_meta->ip_len - skb->head;
+}
+
+/* On some hardware, num_nlos in the coalescing header can be reported
+ * incorrectly under certain conditions even though the per-NLO num_packets
+ * fields it is meant to summarize are correct. Recompute the NLO count from
+ * the contiguous nl_pairs[] prefix rather than trusting the declared value.
+ * The first empty NLO marks the end of the prefix. Entries after it are not
+ * processed.
+ */
+static int rmnet_map_v5_get_num_nlos(const struct rmnet_map_v5_coal_header *coal_hdr)
+{
+ int nlos;
+
+ for (nlos = 0; nlos < RMNET_MAP_V5_MAX_NLOS; nlos++)
+ if (!coal_hdr->nl_pairs[nlos].num_packets)
+ break;
+
+ if (!nlos)
return -EINVAL;
- if (unlikely(!(skb->dev->features & NETIF_F_RXCSUM))) {
- priv->stats.csum_sw++;
- } else if (next_hdr->csum_info & MAPV5_CSUMINFO_VALID_FLAG) {
- priv->stats.csum_ok++;
- skb->ip_summed = CHECKSUM_UNNECESSARY;
+ return nlos;
+}
+
+static void rmnet_map_v5_set_nlos(struct rmnet_map_v5_coal_header *coal_hdr,
+ u8 nlos)
+{
+ coal_hdr->coal_info = u8_encode_bits(nlos, MAPV5_COALINFO_NUM_NLOS_FMASK) |
+ (coal_hdr->coal_info & MAPV5_COALINFO_CSUM_VALID_FLAG);
+}
+
+/* The frame-level CSUM_VALID indication for a single NLO, single packet
+ * coalescing frame cannot be trusted when the close reason is a TCP FIN/PSH,
+ * a packet count limit, a byte count limit or a time limit.
+ */
+static bool rmnet_map_v5_csum_fixup(struct rmnet_map_v5_coal_header *coal_hdr)
+{
+ u8 close_value = u8_get_bits(coal_hdr->close_info,
+ MAPV5_CLOSEINFO_CLOSE_VALUE_FMASK);
+ u8 close_type = u8_get_bits(coal_hdr->close_info,
+ MAPV5_CLOSEINFO_CLOSE_TYPE_FMASK);
+ u8 num_nlos = u8_get_bits(coal_hdr->coal_info,
+ MAPV5_COALINFO_NUM_NLOS_FMASK);
+
+ /* Only applies to single NLO, single packet frames */
+ if (num_nlos != 1 || coal_hdr->nl_pairs[0].num_packets != 1)
+ return false;
+
+ /* TCP FIN or PSH triggered the close */
+ if (close_type == RMNET_MAP_COAL_CLOSE_COAL)
+ return true;
+
+ /* Hit a hardware limit */
+ if (close_type == RMNET_MAP_COAL_CLOSE_HW) {
+ switch (close_value) {
+ case RMNET_MAP_COAL_CLOSE_HW_PKT:
+ case RMNET_MAP_COAL_CLOSE_HW_BYTE:
+ case RMNET_MAP_COAL_CLOSE_HW_TIME:
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/* Carve one logical segment from a coalesced SKB and append it to the list.
+ * Adjusts TCP sequence numbers, IP IDs/lengths, and checksum state.
+ */
+static void
+__rmnet_map_segment_coal_skb(struct sk_buff *coal_skb,
+ struct rmnet_map_coal_metadata *coal_meta,
+ struct sk_buff_head *list, u8 pkt_id,
+ bool csum_valid)
+{
+ u32 dlen = coal_meta->data_len * coal_meta->pkt_count;
+ struct rmnet_priv *priv = netdev_priv(coal_skb->dev);
+ u32 hlen = coal_meta->ip_len + coal_meta->trans_len;
+ struct rmnet_pcpu_stats *pcpu_ptr;
+ struct sk_buff *skbn;
+
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
+
+ /* RFC 768: UDP checksum is optional for IPv4, and is 0 if unused.
+ * Such packets are never actually bad, regardless of what the
+ * checksum bitmap says.
+ */
+ if (!csum_valid && coal_meta->zero_csum)
+ csum_valid = true;
+
+ if (!csum_valid) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ /* rx_dropped is standard accounting. coal_csum_drop is its
+ * coalescing-specific checksum error subset.
+ */
+ u64_stats_add(&pcpu_ptr->priv_stats.rx_dropped, coal_meta->pkt_count);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_csum_drop);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ goto next_pkt;
+ }
+
+ skbn = alloc_skb(hlen + dlen + RMNET_MAP_DEAGGR_HEADROOM, GFP_ATOMIC);
+ if (!skbn) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ /* The coal counter is the coalescing subset of the standard
+ * allocation failure and RX drop counters.
+ */
+ u64_stats_add(&pcpu_ptr->priv_stats.rx_alloc_fail, coal_meta->pkt_count);
+ u64_stats_add(&pcpu_ptr->priv_stats.rx_dropped, coal_meta->pkt_count);
+ u64_stats_add(&pcpu_ptr->priv_stats.coal_alloc_fail, coal_meta->pkt_count);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ goto next_pkt;
+ }
+
+ skb_reserve(skbn, hlen + RMNET_MAP_DEAGGR_HEADROOM);
+ skb_put_data(skbn,
+ coal_skb->data + coal_meta->ip_len + coal_meta->trans_len +
+ coal_meta->data_offset,
+ dlen);
+
+ /* Restore transport header */
+ skb_push(skbn, coal_meta->trans_len);
+ memcpy(skbn->data, coal_meta->trans_header, coal_meta->trans_len);
+ skb_reset_transport_header(skbn);
+
+ if (coal_meta->trans_proto == IPPROTO_TCP) {
+ struct tcphdr *th = tcp_hdr(skbn);
+
+ th->seq = htonl(ntohl(th->seq) + coal_meta->data_offset);
+ /* Strip dangerous flags from non-final segments */
+ if ((th->fin || th->psh) &&
+ hlen + coal_meta->data_offset + dlen < coal_skb->len) {
+ th->fin = 0;
+ th->psh = 0;
+ }
+ } else if (coal_meta->trans_proto == IPPROTO_UDP) {
+ struct udphdr *uh = udp_hdr(skbn);
+
+ uh->len = htons(skbn->len);
+ }
+
+ /* Restore IP header */
+ skb_push(skbn, coal_meta->ip_len);
+ memcpy(skbn->data, coal_meta->ip_header, coal_meta->ip_len);
+ skb_reset_network_header(skbn);
+
+ if (coal_meta->ip_proto == 4) {
+ struct iphdr *iph = ip_hdr(skbn);
+
+ iph->id = htons(ntohs(iph->id) + pkt_id);
+ iph->tot_len = htons(skbn->len);
+ iph->check = 0;
+ iph->check = ip_fast_csum(iph, iph->ihl);
+ } else {
+ ipv6_hdr(skbn)->payload_len =
+ htons(skbn->len - sizeof(struct ipv6hdr));
+ }
+
+ rmnet_map_partial_csum(skbn, coal_meta);
+
+ skbn->dev = coal_skb->dev;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_reconstruct);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+
+ if (coal_meta->pkt_count > 1)
+ rmnet_map_gso_stamp(skbn, coal_meta);
+
+ __skb_queue_tail(list, skbn);
+
+next_pkt:
+ coal_meta->data_offset += dlen;
+ coal_meta->pkt_count = 0;
+}
+
+/* Parse the IP header of the coalesced frame and perform basic
+ * validation of header fields.
+ */
+static bool rmnet_map_coal_parse_ip_hdr(struct sk_buff *coal_skb,
+ struct rmnet_map_coal_metadata *meta,
+ bool *gro)
+{
+ struct rmnet_priv *priv = netdev_priv(coal_skb->dev);
+ struct rmnet_pcpu_stats *pcpu_ptr;
+ struct ipv6hdr *ip6h;
+ struct iphdr *iph;
+ __be16 frag_off;
+ u8 protocol;
+ int ret;
+
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
+
+ if (coal_skb->len < sizeof(*iph)) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_ip_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ iph = (struct iphdr *)coal_skb->data;
+
+ if (iph->version == 4) {
+ meta->ip_proto = 4;
+ meta->ip_len = iph->ihl * 4;
+ meta->trans_proto = iph->protocol;
+ meta->ip_header = iph;
+ if (meta->ip_len < sizeof(*iph) || coal_skb->len < meta->ip_len) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_ip_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ if (ip_is_fragment(iph)) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_ip_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ if (iph->ihl != 5)
+ *gro = false;
+ } else if (iph->version == 6) {
+ if (coal_skb->len < sizeof(*ip6h)) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_ip_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ ip6h = (struct ipv6hdr *)iph;
+ protocol = ip6h->nexthdr;
+ meta->ip_proto = 6;
+ ret = ipv6_skip_exthdr(coal_skb, sizeof(*ip6h), &protocol,
+ &frag_off);
+ if (ret < 0 || frag_off || ret > U16_MAX) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_ip_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ meta->ip_len = (u16)ret;
+ meta->trans_proto = protocol;
+ meta->ip_header = ip6h;
+ if (coal_skb->len < meta->ip_len) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_ip_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ if (meta->ip_len > sizeof(*ip6h))
+ *gro = false;
+ } else {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_ip_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ return true;
+}
+
+/* Parse the transport header following the IP header into coal_meta. The
+ * available length is checked before any field is read.
+ */
+static bool rmnet_map_coal_parse_trans_hdr(struct sk_buff *coal_skb,
+ struct rmnet_map_coal_metadata *meta)
+{
+ struct rmnet_priv *priv = netdev_priv(coal_skb->dev);
+ struct rmnet_pcpu_stats *pcpu_ptr;
+ struct udphdr *uh;
+ struct tcphdr *th;
+ u32 avail;
+ u8 *base;
+
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
+
+ if (meta->ip_len > coal_skb->len) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_trans_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ base = (u8 *)meta->ip_header + meta->ip_len;
+ avail = coal_skb->len - meta->ip_len;
+
+ if (meta->trans_proto == IPPROTO_TCP) {
+ if (avail < sizeof(*th)) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_trans_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ th = (struct tcphdr *)base;
+ meta->trans_len = th->doff * 4;
+ meta->trans_header = th;
+ if (meta->trans_len < sizeof(*th) || avail < meta->trans_len) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_trans_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+ } else if (meta->trans_proto == IPPROTO_UDP) {
+ if (avail < sizeof(*uh)) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_trans_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ uh = (struct udphdr *)base;
+ meta->trans_len = sizeof(*uh);
+ meta->trans_header = uh;
+ if (meta->ip_proto == 4 && !uh->check)
+ meta->zero_csum = true;
} else {
- priv->stats.csum_valid_unset++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_trans_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ return true;
+}
+
+/* Reject the frame unless the total data bytes claimed by all NLOs
+ * exactly match the actual payload in the SKB. Each pkt_len covers
+ * IP+transport headers plus per-packet data. Headers appear once, so
+ * subtract hlen per packet and track the running sum against available
+ * data. An exact match is required, not just an upper bound, so that
+ * GSO metadata stamped from the NLOs stays consistent with the real
+ * SKB length.
+ */
+static bool rmnet_map_coal_validate_bounds(struct sk_buff *coal_skb,
+ struct rmnet_map_v5_coal_header *coal_hdr,
+ u8 num_nlos, u32 hlen, bool *gro)
+{
+ u32 total_data = 0;
+ u32 nlo_len;
+ u16 plen;
+ u8 i;
+
+ if (hlen > coal_skb->len)
+ return false;
+
+ for (i = 0; i < num_nlos; i++) {
+ plen = ntohs(coal_hdr->nl_pairs[i].pkt_len);
+
+ if (plen < hlen)
+ return false;
+
+ /* Zero-payload packets cannot use GSO with a zero gso_size. */
+ if (plen == hlen)
+ *gro = false;
+
+ nlo_len = (u32)(plen - hlen) * coal_hdr->nl_pairs[i].num_packets;
+ if (nlo_len > coal_skb->len - hlen - total_data)
+ return false;
+
+ total_data += nlo_len;
+ }
+
+ return total_data == coal_skb->len - hlen;
+}
+
+/* Attempt the GRO-friendly fast path for a single-NLO, checksum-valid frame
+ * by reusing the original SKB and stamping GSO metadata instead of copying
+ * out each segment. Returns true if the frame was consumed via the fast
+ * path, or false if the caller should fall back to full segmentation.
+ */
+static bool rmnet_map_coal_gro_fast_path(struct sk_buff *coal_skb,
+ struct rmnet_map_v5_coal_header *coal_hdr,
+ struct rmnet_map_coal_metadata *coal_meta,
+ struct sk_buff_head *list,
+ u8 num_nlos, bool gro)
+{
+ u32 hlen = coal_meta->ip_len + coal_meta->trans_len;
+
+ if (!gro || num_nlos != 1 ||
+ !(coal_hdr->coal_info & MAPV5_COALINFO_CSUM_VALID_FLAG))
+ return false;
+
+ coal_meta->data_len = ntohs(coal_hdr->nl_pairs[0].pkt_len) - hlen;
+ coal_meta->pkt_count = coal_hdr->nl_pairs[0].num_packets;
+
+ coal_skb->ip_summed = CHECKSUM_UNNECESSARY;
+ if (coal_meta->pkt_count > 1) {
+ rmnet_map_partial_csum(coal_skb, coal_meta);
+ rmnet_map_gso_stamp(coal_skb, coal_meta);
+ }
+
+ __skb_queue_tail(list, coal_skb);
+ return true;
+}
+
+/* NLO packet lengths are already bounds-checked by
+ * rmnet_map_coal_validate_bounds() so no further validation is needed here.
+ */
+static void rmnet_map_coal_segment_loop(struct sk_buff *coal_skb,
+ struct rmnet_map_v5_coal_header *coal_hdr,
+ struct rmnet_map_coal_metadata *coal_meta,
+ struct sk_buff_head *list,
+ u64 nlo_err_mask, bool gro, u8 num_nlos)
+{
+ struct rmnet_priv *priv = netdev_priv(coal_skb->dev);
+ u32 hlen = coal_meta->ip_len + coal_meta->trans_len;
+ struct rmnet_pcpu_stats *pcpu_ptr;
+ u8 pkt, total_pkt = 0;
+ bool csum_err;
+ u16 pkt_len;
+ u8 nlo;
+
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
+
+ for (nlo = 0; nlo < num_nlos; nlo++) {
+ pkt_len = ntohs(coal_hdr->nl_pairs[nlo].pkt_len);
+ pkt_len -= hlen;
+ coal_meta->data_len = pkt_len;
+
+ /* nlo_err_mask is one flat bitstream across all NLOs. Shift
+ * it once per packet in absolute frame order and do not
+ * re-align at the NLO boundary above. See the comment on
+ * rmnet_map_data_check_coal_header() for why.
+ */
+ for (pkt = 0; pkt < coal_hdr->nl_pairs[nlo].num_packets;
+ pkt++, total_pkt++, nlo_err_mask >>= 1) {
+ csum_err = nlo_err_mask & 1;
+
+ if (csum_err) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_csum_err);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ }
+
+ if (!gro) {
+ coal_meta->pkt_count = 1;
+ __rmnet_map_segment_coal_skb(coal_skb, coal_meta,
+ list, total_pkt,
+ !csum_err);
+ continue;
+ }
+
+ if (csum_err) {
+ if (coal_meta->pkt_count)
+ __rmnet_map_segment_coal_skb(coal_skb,
+ coal_meta,
+ list,
+ total_pkt -
+ coal_meta->pkt_count,
+ true);
+ coal_meta->pkt_count = 1;
+ __rmnet_map_segment_coal_skb(coal_skb, coal_meta,
+ list, total_pkt,
+ false);
+ } else {
+ coal_meta->pkt_count++;
+ }
+ }
+
+ /* Flush remaining packets from this NLO */
+ if (coal_meta->pkt_count)
+ __rmnet_map_segment_coal_skb(coal_skb, coal_meta, list,
+ total_pkt - coal_meta->pkt_count, true);
+ }
+}
+
+/* Expand a coalesced SKB into individual IP packets placed on the list.
+ * NLOs with checksum errors are dropped. __rmnet_map_ingress_handler will
+ * free the SKB in the error case.
+ */
+static int rmnet_map_segment_coal_skb(struct sk_buff *coal_skb,
+ u64 nlo_err_mask,
+ struct sk_buff_head *list,
+ u16 len, u16 total_pkts, u8 num_nlos)
+{
+ bool gro_hw = coal_skb->dev->features & NETIF_F_GRO_HW;
+ bool rxcsum = coal_skb->dev->features & NETIF_F_RXCSUM;
+ struct rmnet_priv *priv = netdev_priv(coal_skb->dev);
+ struct rmnet_map_v5_coal_header *coal_hdr;
+ struct rmnet_map_coal_metadata coal_meta;
+ struct rmnet_pcpu_stats *pcpu_ptr;
+ bool gro = gro_hw;
+ u32 hlen;
+
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
+
+ memset(&coal_meta, 0, sizeof(coal_meta));
+
+ /* Drop any MAP frame padding. The coal header is counted in len */
+ skb_pull(coal_skb, sizeof(struct rmnet_map_header));
+ skb_trim(coal_skb, len);
+ coal_hdr = (struct rmnet_map_v5_coal_header *)coal_skb->data;
+ rmnet_map_v5_set_nlos(coal_hdr, num_nlos);
+ skb_pull(coal_skb, sizeof(*coal_hdr));
+
+ if (!rmnet_map_coal_parse_ip_hdr(coal_skb, &coal_meta, &gro))
+ return -EINVAL;
+
+ if (!rmnet_map_coal_parse_trans_hdr(coal_skb, &coal_meta))
+ return -EINVAL;
+
+ hlen = coal_meta.ip_len + coal_meta.trans_len;
+
+ if (!rmnet_map_coal_validate_bounds(coal_skb, coal_hdr, num_nlos, hlen,
+ &gro)) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_bounds_err);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return -EINVAL;
+ }
+
+ /* Device capability gates coalesced delivery. Packet format can still
+ * disable GSO and use the per-packet fallback below.
+ */
+ if (total_pkts > 1 && (!rxcsum || !gro_hw))
+ return -EINVAL;
+
+ if (gro && total_pkts > 1) {
+ /* Standard counters cover delivered HW-GRO skbs. coal_rx and
+ * coal_pkts cover coalescing input regardless of HW-GRO.
+ */
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.rx_hw_gro_packets);
+ u64_stats_add(&pcpu_ptr->priv_stats.rx_hw_gro_wire_packets, total_pkts);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ }
+
+ if (total_pkts == 1 && (!rxcsum || !gro_hw)) {
+ coal_skb->ip_summed = CHECKSUM_NONE;
+ __skb_queue_tail(list, coal_skb);
+ return 0;
+ }
+
+ if (rmnet_map_v5_csum_fixup(coal_hdr) && !coal_meta.zero_csum) {
+ coal_skb->ip_summed = CHECKSUM_NONE;
+ __skb_queue_tail(list, coal_skb);
+ return 0;
+ }
+
+ if (rmnet_map_coal_gro_fast_path(coal_skb, coal_hdr, &coal_meta, list,
+ num_nlos, gro))
+ return 0;
+
+ rmnet_map_coal_segment_loop(coal_skb, coal_hdr, &coal_meta, list,
+ nlo_err_mask, gro, num_nlos);
+
+ return 0;
+}
+
+/* Log the hardware close-reason counter for a coalescing header. */
+static void rmnet_map_data_log_close_stats(struct rmnet_pcpu_stats *pcpu_ptr,
+ u8 type, u8 code)
+{
+ switch (type) {
+ case RMNET_MAP_COAL_CLOSE_NON_COAL:
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_close_non_coal);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ break;
+ case RMNET_MAP_COAL_CLOSE_IP_MISS:
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_close_ip_miss);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ break;
+ case RMNET_MAP_COAL_CLOSE_TRANS_MISS:
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_close_trans_miss);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ break;
+ case RMNET_MAP_COAL_CLOSE_HW:
+ switch (code) {
+ case RMNET_MAP_COAL_CLOSE_HW_NL:
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_close_hw_nl);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ break;
+ case RMNET_MAP_COAL_CLOSE_HW_PKT:
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_close_hw_pkt);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ break;
+ case RMNET_MAP_COAL_CLOSE_HW_BYTE:
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_close_hw_byte);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ break;
+ case RMNET_MAP_COAL_CLOSE_HW_TIME:
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_close_hw_time);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ break;
+ case RMNET_MAP_COAL_CLOSE_HW_EVICT:
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_close_hw_evict);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ break;
+ default:
+ break;
+ }
+ break;
+ case RMNET_MAP_COAL_CLOSE_COAL:
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_close_coal);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ break;
+ default:
+ break;
}
+}
- /* Pull csum v5 header */
- skb_pull(skb, sizeof(*next_hdr));
+/* Validate the coalescing header and build the checksum error mask.
+ *
+ * Checks performed:
+ * - MAP pkt_len accommodates the coal header (coal header is counted in
+ * pkt_len. pkt_len < sizeof(*coal_hdr) means no payload is possible).
+ * - num_nlos is in [1, RMNET_MAP_V5_MAX_NLOS].
+ * - Total packet count does not exceed RMNET_MAP_V5_MAX_PACKETS.
+ *
+ * nlo_err_mask is NOT six independent per-NLO bitmaps. Each nl_pairs
+ * slot only has room for an 8 bit csum_error_bitmap, but a single NLO
+ * can carry more than 8 packets (up to RMNET_MAP_V5_MAX_PACKETS), so
+ * hardware spills a wide NLO's error bits into the csum_error_bitmap
+ * bytes of the following slots rather than truncating them. The
+ * six bitmap bytes are therefore always concatenated in slot order
+ * into one flat RMNET_MAP_V5_MAX_NLOS * 8 = RMNET_MAP_V5_MAX_PACKETS
+ * bit value, addressed by a packet's absolute position in the frame,
+ * regardless of how many NLOs are actually in use. Receivers must
+ * walk it as a single contiguous stream and must not expect it to
+ * align it at NLO boundaries.
+ */
+static int rmnet_map_data_check_coal_header(struct sk_buff *skb,
+ u64 *nlo_err_mask,
+ u8 *num_nlos,
+ u16 *num_pkts)
+{
+ struct rmnet_map_header *maph = (struct rmnet_map_header *)skb->data;
+ struct rmnet_priv *priv = netdev_priv(skb->dev);
+ struct rmnet_map_v5_coal_header *coal_hdr;
+ struct rmnet_pcpu_stats *pcpu_ptr;
+ u16 pkts = 0;
+ u64 mask = 0;
+ int nlos;
+ int i;
+
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
+
+ /* coal header is counted in pkt_len */
+ if (ntohs(maph->pkt_len) < sizeof(*coal_hdr)) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_hdr_err);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return -EINVAL;
+ }
+
+ coal_hdr = (struct rmnet_map_v5_coal_header *)(skb->data + sizeof(*maph));
+ nlos = rmnet_map_v5_get_num_nlos(coal_hdr);
+ if (nlos < 0) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_hdr_err);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return -EINVAL;
+ }
+
+ *num_nlos = nlos;
+ for (i = 0; i < RMNET_MAP_V5_MAX_NLOS; i++) {
+ u8 err = coal_hdr->nl_pairs[i].csum_error_bitmap;
+ u8 pkt = coal_hdr->nl_pairs[i].num_packets;
+
+ mask |= ((u64)err) << (8 * i);
+ if (i < *num_nlos) {
+ pkts += pkt;
+ if (pkts > RMNET_MAP_V5_MAX_PACKETS) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_hdr_pkt_err);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return -EINVAL;
+ }
+ }
+ }
+
+ /* coal_pkts counts packets reported by the hardware, independent of
+ * whether the frame is later delivered through HW-GRO.
+ */
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_add(&pcpu_ptr->priv_stats.coal_pkts, pkts);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ rmnet_map_data_log_close_stats(pcpu_ptr,
+ u8_get_bits(coal_hdr->close_info,
+ MAPV5_CLOSEINFO_CLOSE_TYPE_FMASK),
+ u8_get_bits(coal_hdr->close_info,
+ MAPV5_CLOSEINFO_CLOSE_VALUE_FMASK));
+
+ *nlo_err_mask = mask;
+ *num_pkts = pkts;
+ return 0;
+}
+
+int rmnet_map_process_next_hdr_packet(struct sk_buff *skb,
+ struct sk_buff_head *list,
+ u16 len, u32 data_format)
+{
+ struct rmnet_priv *priv = netdev_priv(skb->dev);
+ struct rmnet_pcpu_stats *pcpu_ptr;
+ u64 nlo_err_mask;
+ u16 num_pkts;
+ u8 num_nlos;
+ int rc;
+
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
+
+ switch (rmnet_map_get_next_hdr_type(skb)) {
+ case RMNET_MAP_HEADER_TYPE_COALESCING:
+ if (!(data_format & RMNET_FLAGS_INGRESS_COALESCE))
+ return -EINVAL;
+
+ /* coal_rx counts coalescing input, not delivered HW-GRO skbs. */
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_rx);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ rc = rmnet_map_data_check_coal_header(skb, &nlo_err_mask,
+ &num_nlos, &num_pkts);
+ if (rc)
+ return rc;
+
+ /* Coalescing rewrites shared packet data and GSO metadata. */
+ if (skb_unclone(skb, GFP_ATOMIC))
+ return -ENOMEM;
+
+ rc = rmnet_map_segment_coal_skb(skb, nlo_err_mask, list, len,
+ num_pkts, num_nlos);
+ if (rc)
+ return rc;
+
+ if (skb_peek(list) != skb) {
+ if (skb_queue_empty(list))
+ kfree_skb(skb);
+ else
+ consume_skb(skb);
+ }
+ break;
+
+ case RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD:
+ if (unlikely(!(skb->dev->features & NETIF_F_RXCSUM))) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_sw);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ } else if (rmnet_map_get_csum_valid(skb)) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_ok);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+ } else {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_valid_unset);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ }
+
+ skb_pull(skb, sizeof(struct rmnet_map_header) +
+ sizeof(struct rmnet_map_v5_csum_header));
+ skb_trim(skb, len);
+ __skb_queue_tail(list, skb);
+ break;
+
+ default:
+ return -EINVAL;
+ }
return 0;
}
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
index 5f921cddf82b4..8e2a83ca02355 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
@@ -7,6 +7,7 @@
#include <linux/capability.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
+#include <net/netdev_queues.h>
#include <linux/if_arp.h>
#include <linux/netlink.h>
#include <net/pkt_sched.h>
@@ -66,27 +67,25 @@ static netdev_tx_t rmnet_vnd_start_xmit(struct sk_buff *skb,
return NETDEV_TX_OK;
}
-static int rmnet_vnd_headroom(struct rmnet_port *port)
+static int rmnet_vnd_headroom(u32 data_format)
{
u32 headroom;
headroom = sizeof(struct rmnet_map_header);
- if (port->data_format & RMNET_FLAGS_EGRESS_MAP_CKSUMV4)
+ if (data_format & RMNET_FLAGS_EGRESS_MAP_CKSUMV4)
headroom += sizeof(struct rmnet_map_ul_csum_header);
return headroom;
}
-static int rmnet_vnd_change_mtu(struct net_device *rmnet_dev, int new_mtu)
+static int rmnet_vnd_change_mtu_with_format(struct net_device *rmnet_dev,
+ int new_mtu, u32 data_format)
{
struct rmnet_priv *priv = netdev_priv(rmnet_dev);
- struct rmnet_port *port;
u32 headroom;
- port = rmnet_get_port_rtnl(priv->real_dev);
-
- headroom = rmnet_vnd_headroom(port);
+ headroom = rmnet_vnd_headroom(data_format);
if (new_mtu < 0 || new_mtu > RMNET_MAX_PACKET_SIZE ||
new_mtu > (priv->real_dev->mtu - headroom))
@@ -96,6 +95,17 @@ static int rmnet_vnd_change_mtu(struct net_device *rmnet_dev, int new_mtu)
return 0;
}
+static int rmnet_vnd_change_mtu(struct net_device *rmnet_dev, int new_mtu)
+{
+ struct rmnet_priv *priv = netdev_priv(rmnet_dev);
+ struct rmnet_port *port;
+
+ port = rmnet_get_port_rtnl(priv->real_dev);
+
+ return rmnet_vnd_change_mtu_with_format(rmnet_dev, new_mtu,
+ READ_ONCE(port->data_format));
+}
+
static int rmnet_vnd_get_iflink(const struct net_device *dev)
{
struct rmnet_priv *priv = netdev_priv(dev);
@@ -132,7 +142,9 @@ static void rmnet_vnd_uninit(struct net_device *dev)
static void rmnet_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *s)
{
+ struct rmnet_priv_stats total_priv_stats = { };
struct rmnet_priv *priv = netdev_priv(dev);
+ struct rmnet_priv_stats priv_snapshot;
struct rmnet_vnd_stats total_stats = { };
struct rmnet_pcpu_stats *pcpu_ptr;
struct rmnet_vnd_stats snapshot;
@@ -144,6 +156,8 @@ static void rmnet_get_stats64(struct net_device *dev,
do {
start = u64_stats_fetch_begin(&pcpu_ptr->syncp);
snapshot = pcpu_ptr->stats; /* struct assignment */
+ u64_stats_copy(&priv_snapshot, &pcpu_ptr->priv_stats,
+ sizeof(priv_snapshot));
} while (u64_stats_fetch_retry(&pcpu_ptr->syncp, start));
total_stats.rx_pkts += snapshot.rx_pkts;
@@ -151,6 +165,7 @@ static void rmnet_get_stats64(struct net_device *dev,
total_stats.tx_pkts += snapshot.tx_pkts;
total_stats.tx_bytes += snapshot.tx_bytes;
total_stats.tx_drops += snapshot.tx_drops;
+ total_priv_stats.rx_dropped += priv_snapshot.rx_dropped;
}
s->rx_packets = total_stats.rx_pkts;
@@ -158,8 +173,45 @@ static void rmnet_get_stats64(struct net_device *dev,
s->tx_packets = total_stats.tx_pkts;
s->tx_bytes = total_stats.tx_bytes;
s->tx_dropped = total_stats.tx_drops;
+ s->rx_dropped = total_priv_stats.rx_dropped;
}
+/* Report standard network stack RX statistics. These are distinct from the
+ * rmnet-specific coalescing diagnostics exposed through ethtool.
+ */
+static void rmnet_get_queue_stats_rx(struct net_device *dev, int idx,
+ struct netdev_queue_stats_rx *stats)
+{
+ struct rmnet_priv *priv = netdev_priv(dev);
+ struct rmnet_priv_stats total_stats = { };
+ struct rmnet_pcpu_stats *pcpu_ptr;
+ struct rmnet_priv_stats snapshot;
+ unsigned int cpu, start;
+
+ for_each_possible_cpu(cpu) {
+ pcpu_ptr = per_cpu_ptr(priv->pcpu_stats, cpu);
+
+ do {
+ start = u64_stats_fetch_begin(&pcpu_ptr->syncp);
+ u64_stats_copy(&snapshot, &pcpu_ptr->priv_stats,
+ sizeof(snapshot));
+ } while (u64_stats_fetch_retry(&pcpu_ptr->syncp, start));
+
+ total_stats.rx_hw_gro_packets += snapshot.rx_hw_gro_packets;
+ total_stats.rx_hw_gro_wire_packets +=
+ snapshot.rx_hw_gro_wire_packets;
+ total_stats.rx_alloc_fail += snapshot.rx_alloc_fail;
+ }
+
+ stats->hw_gro_packets = total_stats.rx_hw_gro_packets;
+ stats->hw_gro_wire_packets = total_stats.rx_hw_gro_wire_packets;
+ stats->alloc_fail = total_stats.rx_alloc_fail;
+}
+
+static const struct netdev_stat_ops rmnet_stat_ops = {
+ .get_queue_stats_rx = rmnet_get_queue_stats_rx,
+};
+
static const struct net_device_ops rmnet_vnd_ops = {
.ndo_start_xmit = rmnet_vnd_start_xmit,
.ndo_change_mtu = rmnet_vnd_change_mtu,
@@ -183,8 +235,34 @@ static const char rmnet_gstrings_stats[][ETH_GSTRING_LEN] = {
"Checksum skipped",
"Checksum computed in software",
"Checksum computed in hardware",
+ /* DL coalescing */
+ "Coal alloc packet drops",
+ "Coal frames received",
+ "Packets in coal frames",
+ "Coal header errors",
+ "Coal hdr pkt count errors",
+ "Coal bounds errors",
+ "Coal checksum errors",
+ "Coal packets dropped on csum err",
+ "Coal segments reconstructed",
+ "Coal invalid IP packet",
+ "Coal invalid transport",
+ /* close reasons */
+ "Coal closed: non-coal",
+ "Coal closed: IP miss",
+ "Coal closed: transport miss",
+ "Coal closed: hw NL limit",
+ "Coal closed: hw pkt limit",
+ "Coal closed: hw byte limit",
+ "Coal closed: hw time limit",
+ "Coal closed: hw evict",
+ "Coal closed: FIN/PSH",
};
+static_assert(ARRAY_SIZE(rmnet_gstrings_stats) ==
+ (sizeof(struct rmnet_priv_stats) -
+ offsetof(struct rmnet_priv_stats, csum_ok)) / sizeof(u64));
+
static void rmnet_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
{
switch (stringset) {
@@ -209,12 +287,62 @@ static void rmnet_get_ethtool_stats(struct net_device *dev,
struct ethtool_stats *stats, u64 *data)
{
struct rmnet_priv *priv = netdev_priv(dev);
- struct rmnet_priv_stats *st = &priv->stats;
+ struct rmnet_priv_stats total_stats = { };
+ struct rmnet_pcpu_stats *pcpu_ptr;
+ struct rmnet_priv_stats snapshot;
+ unsigned int cpu, start;
if (!data)
return;
- memcpy(data, st, ARRAY_SIZE(rmnet_gstrings_stats) * sizeof(u64));
+ for_each_possible_cpu(cpu) {
+ pcpu_ptr = per_cpu_ptr(priv->pcpu_stats, cpu);
+
+ do {
+ start = u64_stats_fetch_begin(&pcpu_ptr->syncp);
+ u64_stats_copy(&snapshot, &pcpu_ptr->priv_stats,
+ sizeof(snapshot));
+ } while (u64_stats_fetch_retry(&pcpu_ptr->syncp, start));
+
+ total_stats.csum_ok += snapshot.csum_ok;
+ total_stats.csum_ip4_header_bad += snapshot.csum_ip4_header_bad;
+ total_stats.csum_valid_unset += snapshot.csum_valid_unset;
+ total_stats.csum_validation_failed += snapshot.csum_validation_failed;
+ total_stats.csum_err_bad_buffer += snapshot.csum_err_bad_buffer;
+ total_stats.csum_err_invalid_ip_version +=
+ snapshot.csum_err_invalid_ip_version;
+ total_stats.csum_err_invalid_transport +=
+ snapshot.csum_err_invalid_transport;
+ total_stats.csum_fragmented_pkt += snapshot.csum_fragmented_pkt;
+ total_stats.csum_skipped += snapshot.csum_skipped;
+ total_stats.csum_sw += snapshot.csum_sw;
+ total_stats.csum_hw += snapshot.csum_hw;
+ /* Custom rmnet coalescing diagnostics follow. */
+ total_stats.coal_alloc_fail += snapshot.coal_alloc_fail;
+ total_stats.coal_rx += snapshot.coal_rx;
+ total_stats.coal_pkts += snapshot.coal_pkts;
+ total_stats.coal_hdr_err += snapshot.coal_hdr_err;
+ total_stats.coal_hdr_pkt_err += snapshot.coal_hdr_pkt_err;
+ total_stats.coal_bounds_err += snapshot.coal_bounds_err;
+ total_stats.coal_csum_err += snapshot.coal_csum_err;
+ total_stats.coal_csum_drop += snapshot.coal_csum_drop;
+ total_stats.coal_reconstruct += snapshot.coal_reconstruct;
+ total_stats.coal_ip_invalid += snapshot.coal_ip_invalid;
+ total_stats.coal_trans_invalid += snapshot.coal_trans_invalid;
+ total_stats.coal_close_non_coal += snapshot.coal_close_non_coal;
+ total_stats.coal_close_ip_miss += snapshot.coal_close_ip_miss;
+ total_stats.coal_close_trans_miss += snapshot.coal_close_trans_miss;
+ total_stats.coal_close_hw_nl += snapshot.coal_close_hw_nl;
+ total_stats.coal_close_hw_pkt += snapshot.coal_close_hw_pkt;
+ total_stats.coal_close_hw_byte += snapshot.coal_close_hw_byte;
+ total_stats.coal_close_hw_time += snapshot.coal_close_hw_time;
+ total_stats.coal_close_hw_evict += snapshot.coal_close_hw_evict;
+ total_stats.coal_close_coal += snapshot.coal_close_coal;
+ }
+
+ /* The first four fields are reported through netdev queue statistics. */
+ memcpy(data, &total_stats.csum_ok,
+ sizeof(total_stats) - offsetof(struct rmnet_priv_stats, csum_ok));
}
static int rmnet_get_coalesce(struct net_device *dev,
@@ -308,8 +436,7 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
struct rmnet_port *port,
struct net_device *real_dev,
struct rmnet_endpoint *ep,
- struct netlink_ext_ack *extack)
-
+ struct netlink_ext_ack *extack, u32 data_format)
{
struct rmnet_priv *priv = netdev_priv(rmnet_dev);
u32 headroom;
@@ -323,12 +450,16 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
rmnet_dev->hw_features = NETIF_F_RXCSUM;
rmnet_dev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
rmnet_dev->hw_features |= NETIF_F_SG;
+ rmnet_dev->hw_features |= NETIF_F_GRO_HW;
+ rmnet_dev->stat_ops = &rmnet_stat_ops;
priv->real_dev = real_dev;
- headroom = rmnet_vnd_headroom(port);
+ headroom = rmnet_vnd_headroom(data_format);
- if (rmnet_vnd_change_mtu(rmnet_dev, real_dev->mtu - headroom)) {
+ if (rmnet_vnd_change_mtu_with_format(rmnet_dev,
+ real_dev->mtu - headroom,
+ data_format)) {
NL_SET_ERR_MSG_MOD(extack, "Invalid MTU on real dev");
return -EINVAL;
}
@@ -375,17 +506,15 @@ int rmnet_vnd_do_flow_control(struct net_device *rmnet_dev, int enable)
return 0;
}
-int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev)
+static int rmnet_vnd_validate_mtu(struct rmnet_port *port,
+ struct net_device *real_dev, u32 data_format)
{
struct hlist_node *tmp_ep;
struct rmnet_endpoint *ep;
- struct rmnet_port *port;
unsigned long bkt_ep;
u32 headroom;
- port = rmnet_get_port_rtnl(real_dev);
-
- headroom = rmnet_vnd_headroom(port);
+ headroom = rmnet_vnd_headroom(data_format);
hash_for_each_safe(port->muxed_ep, bkt_ep, tmp_ep, ep, hlnode) {
if (ep->egress_dev->mtu > (real_dev->mtu - headroom))
@@ -395,23 +524,39 @@ int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev)
return 0;
}
+int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev)
+{
+ struct rmnet_port *port;
+
+ port = rmnet_get_port_rtnl(real_dev);
+
+ return rmnet_vnd_validate_mtu(port, real_dev,
+ READ_ONCE(port->data_format));
+}
+
int rmnet_vnd_update_dev_mtu(struct rmnet_port *port,
- struct net_device *real_dev)
+ struct net_device *real_dev, u32 data_format)
{
struct hlist_node *tmp_ep;
struct rmnet_endpoint *ep;
unsigned long bkt_ep;
u32 headroom;
+ int new_mtu;
- headroom = rmnet_vnd_headroom(port);
+ headroom = rmnet_vnd_headroom(data_format);
+ if (real_dev->mtu < headroom)
+ return -EINVAL;
+
+ new_mtu = real_dev->mtu - headroom;
+ if (new_mtu > RMNET_MAX_PACKET_SIZE)
+ return -EINVAL;
hash_for_each_safe(port->muxed_ep, bkt_ep, tmp_ep, ep, hlnode) {
- if (ep->egress_dev->mtu <= (real_dev->mtu - headroom))
+ if (ep->egress_dev->mtu <= new_mtu)
continue;
- if (rmnet_vnd_change_mtu(ep->egress_dev,
- real_dev->mtu - headroom))
- return -1;
+ /* The target MTU was validated before updating any endpoint. */
+ WRITE_ONCE(ep->egress_dev->mtu, new_mtu);
}
return 0;
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h
index c2b2baf86894e..901ef36900ac3 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h
@@ -12,7 +12,7 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
struct rmnet_port *port,
struct net_device *real_dev,
struct rmnet_endpoint *ep,
- struct netlink_ext_ack *extack);
+ struct netlink_ext_ack *extack, u32 data_format);
int rmnet_vnd_dellink(u8 id, struct rmnet_port *port,
struct rmnet_endpoint *ep);
void rmnet_vnd_rx_fixup(struct sk_buff *skb, struct net_device *dev);
@@ -21,5 +21,5 @@ void rmnet_vnd_tx_fixup(struct sk_buff *skb, struct net_device *dev);
void rmnet_vnd_setup(struct net_device *dev);
int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev);
int rmnet_vnd_update_dev_mtu(struct rmnet_port *port,
- struct net_device *real_dev);
+ struct net_device *real_dev, u32 data_format);
#endif /* _RMNET_VND_H_ */
diff --git a/include/linux/if_rmnet.h b/include/linux/if_rmnet.h
index c44bf6e80ecb4..5df4d417f3d2c 100644
--- a/include/linux/if_rmnet.h
+++ b/include/linux/if_rmnet.h
@@ -70,5 +70,36 @@ struct rmnet_map_v5_csum_header {
#define MAPV5_HDRINFO_HDR_TYPE_FMASK GENMASK(7, 1)
#define MAPV5_CSUMINFO_VALID_FLAG BIT(7)
+#define RMNET_MAP_HEADER_TYPE_COALESCING 1
#define RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD 2
+
+/* MAPv5 coalescing header */
+#define RMNET_MAP_V5_MAX_NLOS 6
+#define RMNET_MAP_V5_MAX_PACKETS 48
+
+/* One Number-Length Object pair: per-NLO packet count and length. */
+struct rmnet_map_v5_nl_pair {
+ __be16 pkt_len;
+ u8 csum_error_bitmap;
+ u8 num_packets;
+} __aligned(1);
+
+/* MAPv5 coalescing header: describes up to RMNET_MAP_V5_MAX_NLOS NLOs.
+ * The header immediately follows the MAP header in the frame and is
+ * included in the MAP pkt_len field.
+ */
+struct rmnet_map_v5_coal_header {
+ u8 header_info; /* MAPV5_HDRINFO_NXT_HDR_FLAG, MAPV5_HDRINFO_HDR_TYPE_FMASK */
+ u8 coal_info; /* MAPV5_COALINFO_* */
+ u8 close_info; /* MAPV5_CLOSEINFO_* */
+ u8 veid_info; /* MAPV5_VEIDINFO_* */
+ struct rmnet_map_v5_nl_pair nl_pairs[RMNET_MAP_V5_MAX_NLOS];
+} __aligned(1);
+
+#define MAPV5_COALINFO_NUM_NLOS_FMASK GENMASK(6, 4)
+#define MAPV5_COALINFO_CSUM_VALID_FLAG BIT(7)
+#define MAPV5_CLOSEINFO_CLOSE_TYPE_FMASK GENMASK(3, 0)
+#define MAPV5_CLOSEINFO_CLOSE_VALUE_FMASK GENMASK(7, 4)
+#define MAPV5_VEIDINFO_VEID_FMASK GENMASK(3, 0)
+
#endif /* !(_LINUX_IF_RMNET_H_) */
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index 245b362045253..349fcddc6622f 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -2022,6 +2022,7 @@ enum {
#define RMNET_FLAGS_EGRESS_MAP_CKSUMV4 (1U << 3)
#define RMNET_FLAGS_INGRESS_MAP_CKSUMV5 (1U << 4)
#define RMNET_FLAGS_EGRESS_MAP_CKSUMV5 (1U << 5)
+#define RMNET_FLAGS_INGRESS_COALESCE (1U << 6)
enum {
IFLA_RMNET_UNSPEC,
|
| 3/2 | 2026/10/08 01:20 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 32846 output: 17 thoughts: 125 Thoughts: **Analyzing the RMNET Driver and its Virtualization Potential** Okay, so this patch is introducing MAPv5 downlink hardware packet coalescing for the rmnet driver within Qualcomm's rmnet driver. Let's break this down. First, what *is* rmnet? My initial instinct tells me it's likely something related to Qualcomm's cellular hardware, but I need to confirm this. Is it a virtual network device, something like a VLAN or macvlan, that can be readily simulated, or does it require specific, physical Qualcomm hardware to function? The nuances of this are important for understanding its scope. I need to dive into the code itself and the associated Kconfig options. Looking at the Kconfig should quickly reveal the hardware dependencies, if any. Understanding the architecture and whether rmnet is purely a software construct or a hardware-dependent one is crucial before determining its accessibility within virtualized environments. This is particularly relevant if I am going to try and reproduce any effects here, or look at things like fuzzing and how they might apply in QEMU or syzkaller. |
| 4/2 | 2026/10/08 01:20 | tool | grepper |
0mArgs:{
"Expression": "config RMNET"
}Results: {
"Output": "drivers/net/ethernet/qualcomm/rmnet/Kconfig-5-\ndrivers/net/ethernet/qualcomm/rmnet/Kconfig:6:menuconfig RMNET\ndrivers/net/ethernet/qualcomm/rmnet/Kconfig-7-\ttristate \"RmNet MAP driver\"\n"
} |
| 5/2 | 2026/10/08 01:20 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 33296 output: 41 thoughts: 30 Thoughts: Okay, here's my interpretation of that thought process, assuming I'm already quite familiar with networking drivers and Qualcomm's RMNET implementation: **Diving into the RMNET Configuration** Alright, the objective is to understand the configuration and underlying implementation of RMNET. Given that, my first step is to zero in on the relevant Kconfig and C files. Specifically, I need to check `drivers/net/ethernet/qualcomm/rmnet/Kconfig` to see how RMNET features are exposed and controlled via kernel configuration options. This will quickly tell me what's enabled, disabled, and what options exist. Then, I'll need to look at `rmnet_config.c` to see how those config options are interpreted and how the RMNET driver is actually initialized and configured based on those settings. That will give me a good handle on how the core logic is structured relative to the configuration knobs we have available. Let's see what we can find. |
| 6/2 | 2026/10/08 01:20 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/qualcomm/rmnet/Kconfig",
"FirstLine": 1,
"LineCount": 40
}Results: {
"Contents": " 1:\t# SPDX-License-Identifier: GPL-2.0-only\n 2:\t#\n 3:\t# RMNET MAP driver\n 4:\t#\n 5:\t\n 6:\tmenuconfig RMNET\n 7:\t\ttristate \"RmNet MAP driver\"\n 8:\t\tdefault n\n 9:\t\tselect GRO_CELLS\n 10:\t\thelp\n 11:\t\t If you select this, you will enable the RMNET module which is used\n 12:\t\t for handling data in the multiplexing and aggregation protocol (MAP)\n 13:\t\t format in the embedded data path. RMNET devices can be attached to\n 14:\t\t any IP mode physical device.\n"
} |
| 7/2 | 2026/10/08 01:20 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 33754 output: 39 thoughts: 63 Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience: **RMNET Inquiry: Initial Assessment and Architectural Questions** Alright, that statement about RMNET devices being "attached to any IP mode physical device" got me thinking. My first immediate question is, "Hold on, is RMNET *really* just another rtnl_link_ops virtual device?" That's a fundamental architectural question I need to answer before proceeding. My immediate reflex is to dive into the kernel source to confirm the model. The behavior and implementation are, of course, the heart of the matter. Therefore, I need to understand how these RMNET links are registered within the system and how the packet reception pathway is implemented. I need to get into `rmnet_config.c` to see the details of registration and packet handling to resolve this quickly and definitively. |
| 8/2 | 2026/10/08 01:20 | tool | grepper |
0mArgs:{
"Expression": "rtnl_link_ops",
"PathPrefixes": [
"drivers/net/ethernet/qualcomm/rmnet"
]
}Results: {
"Output": "drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=426=static int rmnet_fill_info(struct sk_buff *skb, const struct net_device *dev)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-447-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:448:struct rtnl_link_ops rmnet_link_ops __read_mostly = {\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-449-\t.kind\t\t= \"rmnet\",\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.h=33=struct rmnet_port {\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.h-55-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.h:56:extern struct rtnl_link_ops rmnet_link_ops;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.h-57-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c=435=int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-472-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:473:\t\trmnet_dev-\u003ertnl_link_ops = \u0026rmnet_link_ops;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-474-\n"
} |
| 9/2 | 2026/10/08 01:20 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 34471 output: 47 thoughts: 67 Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience: **Investigating the Nature and Flexibility of `rmnet`** Right, so `rmnet` is evidently an `rtnl_link_ops` implementation. That's the starting point. My immediate question is, how versatile is this? Can I instantiate an `rmnet` link *over* any underlying `net_device`? Can I, for example, build an `rmnet` instance on top of a `dummy` interface, a `loopback`, or even a `veth` pair? The best place to investigate that is going to be within `rmnet_config.c`, specifically the `rmnet_newlink` function. I need to understand what constraints, if any, are placed on the underlying device type during link creation. That function is where the rubber meets the road, where the assumptions about the parent interface will be laid bare. My analysis will focus on what this function expects and what, if anything, limits this `rmnet` creation on top of these standard interfaces. |
| 10/2 | 2026/10/08 01:20 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c",
"FirstLine": 120,
"LineCount": 80
}Results: {
"Contents": " 120:\t\n 121:\t\tif (port-\u003ermnet_mode != RMNET_EPMODE_BRIDGE)\n 122:\t\t\treturn;\n 123:\t\n 124:\t\trmnet_dev = port-\u003ermnet_dev;\n 125:\t\tif (!port-\u003enr_rmnet_devs) {\n 126:\t\t\t/* bridge device */\n 127:\t\t\treal_dev = port-\u003ebridge_ep;\n 128:\t\t\tbridge_dev = port-\u003edev;\n 129:\t\n 130:\t\t\treal_port = rmnet_get_port_rtnl(real_dev);\n 131:\t\t\treal_port-\u003ebridge_ep = NULL;\n 132:\t\t\treal_port-\u003ermnet_mode = RMNET_EPMODE_VND;\n 133:\t\t} else {\n 134:\t\t\t/* real device */\n 135:\t\t\tbridge_dev = port-\u003ebridge_ep;\n 136:\t\n 137:\t\t\tport-\u003ebridge_ep = NULL;\n 138:\t\t\tport-\u003ermnet_mode = RMNET_EPMODE_VND;\n 139:\t\t}\n 140:\t\n 141:\t\tnetdev_upper_dev_unlink(bridge_dev, rmnet_dev);\n 142:\t\trmnet_unregister_real_device(bridge_dev);\n 143:\t}\n 144:\t\n 145:\tstatic int rmnet_newlink(struct net_device *dev,\n 146:\t\t\t\t struct rtnl_newlink_params *params,\n 147:\t\t\t\t struct netlink_ext_ack *extack)\n 148:\t{\n 149:\t\tstruct net *link_net = rtnl_newlink_link_net(params);\n 150:\t\tu32 data_format = RMNET_FLAGS_INGRESS_DEAGGREGATION;\n 151:\t\tstruct nlattr **data = params-\u003edata;\n 152:\t\tstruct nlattr **tb = params-\u003etb;\n 153:\t\tstruct net_device *real_dev;\n 154:\t\tint mode = RMNET_EPMODE_VND;\n 155:\t\tstruct rmnet_endpoint *ep;\n 156:\t\tstruct rmnet_port *port;\n 157:\t\tint err = 0;\n 158:\t\tu16 mux_id;\n 159:\t\n 160:\t\tif (!tb[IFLA_LINK]) {\n 161:\t\t\tNL_SET_ERR_MSG_MOD(extack, \"link not specified\");\n 162:\t\t\treturn -EINVAL;\n 163:\t\t}\n 164:\t\n 165:\t\treal_dev = __dev_get_by_index(link_net, nla_get_u32(tb[IFLA_LINK]));\n 166:\t\tif (!real_dev) {\n 167:\t\t\tNL_SET_ERR_MSG_MOD(extack, \"link does not exist\");\n 168:\t\t\treturn -ENODEV;\n 169:\t\t}\n 170:\t\n 171:\t\tif (data[IFLA_RMNET_FLAGS]) {\n 172:\t\t\tstruct ifla_rmnet_flags *flags;\n 173:\t\n 174:\t\t\tflags = nla_data(data[IFLA_RMNET_FLAGS]);\n 175:\t\t\tdata_format \u0026= ~flags-\u003emask;\n 176:\t\t\tdata_format |= flags-\u003eflags \u0026 flags-\u003emask;\n 177:\t\t}\n 178:\t\n 179:\t\tif (!rmnet_config_data_format_valid(data_format)) {\n 180:\t\t\tNL_SET_ERR_MSG_MOD(extack,\n 181:\t\t\t\t\t \"unsupported MAP checksum flag combination\");\n 182:\t\t\treturn -EINVAL;\n 183:\t\t}\n 184:\t\n 185:\t\tep = kzalloc_obj(*ep);\n 186:\t\tif (!ep)\n 187:\t\t\treturn -ENOMEM;\n 188:\t\n 189:\t\tmux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]);\n 190:\t\n 191:\t\terr = rmnet_register_real_device(real_dev, extack);\n 192:\t\tif (err)\n 193:\t\t\tgoto err0;\n 194:\t\n 195:\t\tport = rmnet_get_port_rtnl(real_dev);\n 196:\t\terr = rmnet_vnd_newlink(mux_id, dev, port, real_dev, ep, extack,\n 197:\t\t\t\t\tdata_format);\n 198:\t\tif (err)\n 199:\t\t\tgoto err1;\n"
} |
| 11/2 | 2026/10/08 01:20 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 36055 output: 41 thoughts: 36 Thoughts: Okay, here's my interpretation of what's going on, thinking through this `rmnet_register_real_device` function: **Diving into Real Device Registration** Alright, I'm looking at this `rmnet_register_real_device(real_dev, extack)` function call. Let's break this down. My initial thought is, "What does this registration process *really* entail?" It's clear that `rmnet` has a mechanism for associating "real" devices (whatever those are, specifically, and the structure of `real_dev` is likely key) with its internal framework. The `rmnet` prefix immediately indicates this is probably related to Radio Modem Network. I'm instantly wondering what the device registration process actually encompasses. Is it just adding a pointer to a list somewhere? Does it trigger some hardware initialization? Are there resource allocations happening? It’s probably more than just a simple list insertion, given the context. `extack` is likely related to external acknowledgement signaling, is this a return value or an additional parameter? This gives me the hint of the complexities of asynchronous operation or error signaling. It's likely that a more complex setup is occurring. My next step would be to delve into the function definition itself to find out. I'm assuming the function will deal with the complexities of device management within `rmnet`. We need to figure out what happens when this real device is registered and what implications that has on the rmnet system. This is where the juicy details of device interaction with the network will be unveiled. I'll need to follow the execution path to figure out what exactly happens here. |
| 12/2 | 2026/10/08 01:20 | tool | grepper |
0mArgs:{
"Expression": "rmnet_register_real_device",
"PathPrefixes": [
"drivers/net/ethernet/qualcomm/rmnet"
]
}Results: {
"Output": "drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=61=static int rmnet_unregister_real_device(struct net_device *real_dev)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-77-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:78:static int rmnet_register_real_device(struct net_device *real_dev,\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-79-\t\t\t\t struct netlink_ext_ack *extack)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=145=static int rmnet_newlink(struct net_device *dev,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-190-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:191:\terr = rmnet_register_real_device(real_dev, extack);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-192-\tif (err)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=487=int rmnet_add_bridge(struct net_device *rmnet_dev,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-523-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:524:\terr = rmnet_register_real_device(slave_dev, extack);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-525-\tif (err)\n"
} |
| 13/2 | 2026/10/08 01:20 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 36931 output: 46 thoughts: 14 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience, and written as if they were my own: **Diving into `rmnet_register_real_device`** Alright, let's get down to brass tacks. I need to take a close look at `rmnet_register_real_device`. This function is fundamental, right? It's the point where we're actually tying a physical device, a real piece of hardware, into the RMNET framework. That means understanding its role is absolutely critical to grasping how the RMNET stack interacts with the actual modem interface. I'm thinking about the implications for data path registration, interrupt handling, and likely, a lot of low-level hardware configuration. I'll need to go through the code carefully. I'll be looking for things like memory allocation, interrupt registration, interaction with the device driver model, and error handling – I'll be particularly interested in race conditions or potential deadlocks in its implementation. It could be an early part of the bringup sequence, so anything it does could have deep implications. I'll probably look for its callers and callees too; a good call graph is almost always the best place to start. Let's see what secrets it holds. |
| 14/2 | 2026/10/08 01:20 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c",
"FirstLine": 70,
"LineCount": 45
}Results: {
"Contents": " 70:\t\tnetdev_rx_handler_unregister(real_dev);\n 71:\t\n 72:\t\tkfree(port);\n 73:\t\n 74:\t\tnetdev_dbg(real_dev, \"Removed from rmnet\\n\");\n 75:\t\treturn 0;\n 76:\t}\n 77:\t\n 78:\tstatic int rmnet_register_real_device(struct net_device *real_dev,\n 79:\t\t\t\t\t struct netlink_ext_ack *extack)\n 80:\t{\n 81:\t\tstruct rmnet_port *port;\n 82:\t\tint rc, entry;\n 83:\t\n 84:\t\tASSERT_RTNL();\n 85:\t\n 86:\t\tif (rmnet_is_real_dev_registered(real_dev)) {\n 87:\t\t\tport = rmnet_get_port_rtnl(real_dev);\n 88:\t\t\tif (port-\u003ermnet_mode != RMNET_EPMODE_VND) {\n 89:\t\t\t\tNL_SET_ERR_MSG_MOD(extack, \"bridge device already exists\");\n 90:\t\t\t\treturn -EINVAL;\n 91:\t\t\t}\n 92:\t\n 93:\t\t\treturn 0;\n 94:\t\t}\n 95:\t\n 96:\t\tport = kzalloc_obj(*port);\n 97:\t\tif (!port)\n 98:\t\t\treturn -ENOMEM;\n 99:\t\n 100:\t\tport-\u003edev = real_dev;\n 101:\t\trc = netdev_rx_handler_register(real_dev, rmnet_rx_handler, port);\n 102:\t\tif (rc) {\n 103:\t\t\tkfree(port);\n 104:\t\t\treturn -EBUSY;\n 105:\t\t}\n 106:\t\n 107:\t\tfor (entry = 0; entry \u003c RMNET_MAX_LOGICAL_EP; entry++)\n 108:\t\t\tINIT_HLIST_HEAD(\u0026port-\u003emuxed_ep[entry]);\n 109:\t\n 110:\t\trmnet_map_tx_aggregate_init(port);\n 111:\t\n 112:\t\tnetdev_dbg(real_dev, \"registered with rmnet\\n\");\n 113:\t\treturn 0;\n 114:\t}\n"
} |
| 15/2 | 2026/10/08 01:20 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 37869 output: 39 thoughts: 112 Thoughts: **Diving into the Rmnet Packet Handling** Okay, so I'm seeing this `netdev_rx_handler_register` call, specifically with `real_dev`, our `rmnet_rx_handler`, and a `port` as the parameters. Ah, I see, this is the crux of the connection! Basically, anytime we use a `net_device` like veth, dummy, tap, or loopback and designate it as an `IFLA_LINK`, `rmnet` jumps in and registers its `rmnet_rx_handler` on that interface. Right, so packets coming in on `real_dev` will be processed by that `rmnet_rx_handler`. Now, I need to understand what that handler is actually *doing*. Time to open `rmnet_handlers.c` and dig into `rmnet_rx_handler`. Let's see how the magic happens! |
| 16/2 | 2026/10/08 01:21 | tool | grepper |
0mArgs:{
"Expression": "rmnet_rx_handler",
"PathPrefixes": [
"drivers/net/ethernet/qualcomm/rmnet"
]
}Results: {
"Output": "drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=24=static int rmnet_is_real_dev_registered(const struct net_device *real_dev)\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-25-{\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:26:\treturn rcu_access_pointer(real_dev-\u003erx_handler) == rmnet_rx_handler;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-27-}\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=78=static int rmnet_register_real_device(struct net_device *real_dev,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-100-\tport-\u003edev = real_dev;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:101:\trc = netdev_rx_handler_register(real_dev, rmnet_rx_handler, port);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-102-\tif (rc) {\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c=205=rmnet_bridge_handler(struct sk_buff *skb, struct net_device *bridge_dev)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c-221- */\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c:222:rx_handler_result_t rmnet_rx_handler(struct sk_buff **pskb)\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c-223-{\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.h=12=void rmnet_egress_handler(struct sk_buff *skb);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.h-13-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.h:14:rx_handler_result_t rmnet_rx_handler(struct sk_buff **pskb);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.h-15-\n"
} |
| 17/2 | 2026/10/08 01:21 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 38821 output: 47 thoughts: 21 Thoughts: Okay, let's dive into this. Here's my thought process on tackling this: **Analyzing `rmnet_rx_handler` in `rmnet_handlers.c`** Alright, the next logical step is to pinpoint the function responsible for receiving data within the RMNET framework. My initial thought is to navigate to `rmnet_handlers.c` and specifically examine the `rmnet_rx_handler` function. This seems like the most likely candidate for handling incoming network traffic. I'll need to understand how it's implemented and interacts with other RMNET components. I'll be looking for how it determines the type of incoming packet, where it routes the data, and how it handles potential errors. Understanding the data flow from the hardware to the network stack is crucial, so I'll be paying close attention to any packet processing or buffering that occurs here. My goal is to gain a solid grasp of this function's role in the receive path. |
| 18/2 | 2026/10/08 01:21 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c",
"FirstLine": 220,
"LineCount": 45
}Results: {
"Contents": " 220:\t * egress device listed in the logical endpoint configuration.\n 221:\t */\n 222:\trx_handler_result_t rmnet_rx_handler(struct sk_buff **pskb)\n 223:\t{\n 224:\t\tstruct sk_buff *skb = *pskb;\n 225:\t\tstruct rmnet_port *port;\n 226:\t\tstruct net_device *dev;\n 227:\t\n 228:\t\tif (!skb)\n 229:\t\t\tgoto done;\n 230:\t\n 231:\t\tif (skb_linearize(skb)) {\n 232:\t\t\tkfree_skb(skb);\n 233:\t\t\tgoto done;\n 234:\t\t}\n 235:\t\n 236:\t\tif (skb-\u003epkt_type == PACKET_LOOPBACK)\n 237:\t\t\treturn RX_HANDLER_PASS;\n 238:\t\n 239:\t\tdev = skb-\u003edev;\n 240:\t\tport = rmnet_get_port_rcu(dev);\n 241:\t\tif (unlikely(!port)) {\n 242:\t\t\tdev_core_stats_rx_nohandler_inc(skb-\u003edev);\n 243:\t\t\tkfree_skb(skb);\n 244:\t\t\tgoto done;\n 245:\t\t}\n 246:\t\n 247:\t\tswitch (port-\u003ermnet_mode) {\n 248:\t\tcase RMNET_EPMODE_VND:\n 249:\t\t\trmnet_map_ingress_handler(skb, port);\n 250:\t\t\tbreak;\n 251:\t\tcase RMNET_EPMODE_BRIDGE:\n 252:\t\t\trmnet_bridge_handler(skb, port-\u003ebridge_ep);\n 253:\t\t\tbreak;\n 254:\t\t}\n 255:\t\n 256:\tdone:\n 257:\t\treturn RX_HANDLER_CONSUMED;\n 258:\t}\n 259:\t\n 260:\t/* Modifies packet as per logical endpoint configuration and egress data format\n 261:\t * for egress device configured in logical endpoint. Packet is then transmitted\n 262:\t * on the egress device.\n 263:\t */\n 264:\tvoid rmnet_egress_handler(struct sk_buff *skb)\n"
} |
| 19/2 | 2026/10/08 01:21 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 39722 output: 40 thoughts: 1453 Thoughts: **Vulnerability Assessment: rmnet Module - A Prime Fuzzing Target** Okay, here's the breakdown of my thinking: the `rmnet` module looks like a goldmine for fuzzing. I started tracing the data flow from `rmnet_rx_handler` to `rmnet_map_ingress_handler` and down the rabbit hole to `__rmnet_map_ingress_handler` which then leads to `rmnet_map_process_next_hdr_packet` and all the routines it calls. Specifically: `rmnet_map_data_check_coal_header`, `rmnet_map_segment_coal_skb`, `rmnet_map_coal_parse_ip_hdr`, `rmnet_map_coal_parse_trans_hdr`, `rmnet_map_coal_validate_bounds`, `rmnet_map_coal_gro_fast_path`, `rmnet_map_coal_segment_loop`, `__rmnet_map_segment_coal_skb`, and several others dealing with MTU and statistics. This is all reachable in a standard QEMU environment, which is a huge plus. We can create an `rmnet` netdev using standard netlink calls (`RTM_NEWLINK`), attach it to a dummy or veth device (via `IFLA_LINK` and `IFLA_RMNET_FLAGS`), and then inject packets to trigger this entire flow. Syzkaller supports `nl_link_req` with various link kinds, so that check is done. The recent diffs highlight all the key functions involved in packet parsing, memory allocation, TCP/UDP/IPv4/IPv6 header parsing, checksum manipulation, GSO metadata handling, and segmentation. This is high-value target material. Lots of code means lots of surface area for bugs, complex parsing logic, potential off-by-one errors, bounds checks, memory corruptions and crashes. Now, let's address the negative criteria. The code changes are clearly kernel-level and executable. What about the hardware dependency? I need to clarify whether `rmnet` requires specific physical hardware. Looking at the Kconfig, it states that "RMNET devices can be attached to any IP mode physical device." This is key! I need to confirm if it can be attached to virtual devices like dummy or veth. I checked `rmnet_newlink` and `rmnet_register_real_device`, and it uses `__dev_get_by_index` to fetch real devices, which could be virtual. And then `rmnet_register_real_device` registers the rx handler which further supports the idea. So, it appears `rmnet` *can* be attached to virtual devices. No hardware dependency! Therefore, this whole module is prime territory for fuzzer development. I should prioritize it. |
| 20/2 | 2026/10/08 01:21 | tool | grepper |
0mArgs:{
"Expression": "rmnet_vnd_newlink",
"PathPrefixes": [
"drivers/net/ethernet/qualcomm/rmnet"
]
}Results: {
"Output": "drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=145=static int rmnet_newlink(struct net_device *dev,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-195-\tport = rmnet_get_port_rtnl(real_dev);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:196:\terr = rmnet_vnd_newlink(mux_id, dev, port, real_dev, ep, extack,\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-197-\t\t\t\tdata_format);\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c=409=void rmnet_vnd_setup(struct net_device *rmnet_dev)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-434-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:435:int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-436-\t\t struct rmnet_port *port,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h=10=int rmnet_vnd_do_flow_control(struct net_device *dev, int enable);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h:11:int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h-12-\t\t struct rmnet_port *port,\n"
} |
| 21/2 | 2026/10/08 01:21 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 42284 output: 47 thoughts: 22 Thoughts: Here's my analysis of the provided text, rendered in the first person, assuming an expert user: **Diving into `rmnet_vnd_newlink`** Okay, so we're looking at `rmnet_vnd_newlink`, specifically within `rmnet_vnd.c`. That function's the key to bringing up a new virtual network link in the RMNET environment. Right off the bat, I know this is where the magic happens for creating the interface, managing resources, and configuring the data path. I'll need to understand how it's integrated into the larger RMNET architecture to see how new links are created and what kind of setup happens. I'm going to want to examine the function's arguments to determine how it is called and why. Based on the name it looks like a fairly standard link setup procedure, but I want to see if there are any specific RMNET or vendor specific peculiarities in there. |
| 22/2 | 2026/10/08 01:21 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c",
"FirstLine": 435,
"LineCount": 60
}Results: {
"Contents": " 435:\tint rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,\n 436:\t\t\t struct rmnet_port *port,\n 437:\t\t\t struct net_device *real_dev,\n 438:\t\t\t struct rmnet_endpoint *ep,\n 439:\t\t\t struct netlink_ext_ack *extack, u32 data_format)\n 440:\t{\n 441:\t\tstruct rmnet_priv *priv = netdev_priv(rmnet_dev);\n 442:\t\tu32 headroom;\n 443:\t\tint rc;\n 444:\t\n 445:\t\tif (rmnet_get_endpoint(port, id)) {\n 446:\t\t\tNL_SET_ERR_MSG_MOD(extack, \"MUX ID already exists\");\n 447:\t\t\treturn -EBUSY;\n 448:\t\t}\n 449:\t\n 450:\t\trmnet_dev-\u003ehw_features = NETIF_F_RXCSUM;\n 451:\t\trmnet_dev-\u003ehw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;\n 452:\t\trmnet_dev-\u003ehw_features |= NETIF_F_SG;\n 453:\t\trmnet_dev-\u003ehw_features |= NETIF_F_GRO_HW;\n 454:\t\trmnet_dev-\u003estat_ops = \u0026rmnet_stat_ops;\n 455:\t\n 456:\t\tpriv-\u003ereal_dev = real_dev;\n 457:\t\n 458:\t\theadroom = rmnet_vnd_headroom(data_format);\n 459:\t\n 460:\t\tif (rmnet_vnd_change_mtu_with_format(rmnet_dev,\n 461:\t\t\t\t\t\t real_dev-\u003emtu - headroom,\n 462:\t\t\t\t\t\t data_format)) {\n 463:\t\t\tNL_SET_ERR_MSG_MOD(extack, \"Invalid MTU on real dev\");\n 464:\t\t\treturn -EINVAL;\n 465:\t\t}\n 466:\t\n 467:\t\trc = register_netdevice(rmnet_dev);\n 468:\t\tif (!rc) {\n 469:\t\t\tep-\u003eegress_dev = rmnet_dev;\n 470:\t\t\tep-\u003emux_id = id;\n 471:\t\t\tport-\u003enr_rmnet_devs++;\n 472:\t\n 473:\t\t\trmnet_dev-\u003ertnl_link_ops = \u0026rmnet_link_ops;\n 474:\t\n 475:\t\t\tWRITE_ONCE(priv-\u003emux_id, id);\n 476:\t\n 477:\t\t\tnetdev_dbg(rmnet_dev, \"rmnet dev created\\n\");\n 478:\t\t}\n 479:\t\n 480:\t\treturn rc;\n 481:\t}\n 482:\t\n 483:\tint rmnet_vnd_dellink(u8 id, struct rmnet_port *port,\n 484:\t\t\t struct rmnet_endpoint *ep)\n 485:\t{\n 486:\t\tif (id \u003e= RMNET_MAX_LOGICAL_EP || !ep-\u003eegress_dev)\n 487:\t\t\treturn -EINVAL;\n 488:\t\n 489:\t\tep-\u003eegress_dev = NULL;\n 490:\t\tport-\u003enr_rmnet_devs--;\n 491:\t\treturn 0;\n 492:\t}\n 493:\t\n 494:\tint rmnet_vnd_do_flow_control(struct net_device *rmnet_dev, int enable)\n"
} |
| 23/2 | 2026/10/08 01:21 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 43519 output: 19 thoughts: 53 Thoughts: Okay, let's see... **My Current Analysis of RMNET Network Device Creation** Right, so I'm looking at this RMNET netdev creation and the immediate impression is... *there's no actual hardware verification happening!* That's a huge oversight, if true. Any `real_dev`—a dummy network device, a veth pair, a loopback, whatever—can simply have an RMNET netdev layered on top of it. This raises some serious questions about the intended design and potential vulnerabilities. My next step is to quickly dig into the syzkaller syzlang definitions. I need to know if we already have support, implicitly or explicitly, for RMNET netdevs within that framework. If not, we have some significant work to do, and I'll need to figure out the best way to integrate it. This lack of hardware check is concerning, but I need to understand the wider ecosystem before I can assess the true implications of this design. Let's see what the syzkaller definitions have to say. |
| 24/2 | 2026/10/08 01:21 | tool | grepper |
0mArgs:{
"Expression": "IFLA_RMNET"
}Results: {
"Output": "Documentation/networking/device_drivers/cellular/qualcomm/rmnet.rst=313=The data format flags controlling the ingress and egress processing\nDocumentation/networking/device_drivers/cellular/qualcomm/rmnet.rst:314:pipeline are set via the ``IFLA_RMNET_FLAGS`` attribute\nDocumentation/networking/device_drivers/cellular/qualcomm/rmnet.rst-315-(``struct ifla_rmnet_flags``).\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-18-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:19:static const struct nla_policy rmnet_policy[IFLA_RMNET_MAX + 1] = {\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:20:\t[IFLA_RMNET_MUX_ID]\t= { .type = NLA_U16 },\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:21:\t[IFLA_RMNET_FLAGS]\t= { .len = sizeof(struct ifla_rmnet_flags) },\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-22-};\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=145=static int rmnet_newlink(struct net_device *dev,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-170-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:171:\tif (data[IFLA_RMNET_FLAGS]) {\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-172-\t\tstruct ifla_rmnet_flags *flags;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-173-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:174:\t\tflags = nla_data(data[IFLA_RMNET_FLAGS]);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-175-\t\tdata_format \u0026= ~flags-\u003emask;\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-188-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:189:\tmux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-190-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=319=static int rmnet_rtnl_validate(struct nlattr *tb[], struct nlattr *data[],\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-323-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:324:\tif (!data || !data[IFLA_RMNET_MUX_ID]) {\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-325-\t\tNL_SET_ERR_MSG_MOD(extack, \"MUX ID not specified\");\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-328-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:329:\tmux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-330-\tif (mux_id \u003e (RMNET_MAX_LOGICAL_EP - 1)) {\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=338=static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-365-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:366:\tif (data[IFLA_RMNET_FLAGS]) {\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-367-\t\told_data_format = READ_ONCE(port-\u003edata_format);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:368:\t\tflags = nla_data(data[IFLA_RMNET_FLAGS]);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-369-\t\tdata_format = old_data_format \u0026 ~flags-\u003emask;\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-378-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:379:\tif (data[IFLA_RMNET_MUX_ID]) {\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:380:\t\tmux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-381-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-403-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:404:\tif (data[IFLA_RMNET_FLAGS]) {\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-405-\t\terr = rmnet_vnd_update_dev_mtu(port, real_dev, data_format);\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=417=static size_t rmnet_get_size(const struct net_device *dev)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-419-\treturn\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:420:\t\t/* IFLA_RMNET_MUX_ID */\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-421-\t\tnla_total_size(2) +\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:422:\t\t/* IFLA_RMNET_FLAGS */\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-423-\t\tnla_total_size(sizeof(struct ifla_rmnet_flags));\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=426=static int rmnet_fill_info(struct sk_buff *skb, const struct net_device *dev)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-431-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:432:\tif (nla_put_u16(skb, IFLA_RMNET_MUX_ID, READ_ONCE(priv-\u003emux_id)))\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-433-\t\treturn -EMSGSIZE;\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-441-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:442:\tif (nla_put(skb, IFLA_RMNET_FLAGS, sizeof(f), \u0026f))\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-443-\t\treturn -EMSGSIZE;\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=448=struct rtnl_link_ops rmnet_link_ops __read_mostly = {\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-449-\t.kind\t\t= \"rmnet\",\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:450:\t.maxtype\t= IFLA_RMNET_MAX,\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-451-\t.priv_size\t= sizeof(struct rmnet_priv),\n--\ninclude/uapi/linux/if_link.h=2027=enum {\ninclude/uapi/linux/if_link.h:2028:\tIFLA_RMNET_UNSPEC,\ninclude/uapi/linux/if_link.h:2029:\tIFLA_RMNET_MUX_ID,\ninclude/uapi/linux/if_link.h:2030:\tIFLA_RMNET_FLAGS,\ninclude/uapi/linux/if_link.h:2031:\t__IFLA_RMNET_MAX,\ninclude/uapi/linux/if_link.h-2032-};\ninclude/uapi/linux/if_link.h-2033-\ninclude/uapi/linux/if_link.h:2034:#define IFLA_RMNET_MAX\t(__IFLA_RMNET_MAX - 1)\ninclude/uapi/linux/if_link.h-2035-\n--\ntools/include/uapi/linux/if_link.h=1946=enum {\ntools/include/uapi/linux/if_link.h:1947:\tIFLA_RMNET_UNSPEC,\ntools/include/uapi/linux/if_link.h:1948:\tIFLA_RMNET_MUX_ID,\ntools/include/uapi/linux/if_link.h:1949:\tIFLA_RMNET_FLAGS,\ntools/include/uapi/linux/if_link.h:1950:\t__IFLA_RMNET_MAX,\ntools/include/uapi/linux/if_link.h-1951-};\ntools/include/uapi/linux/if_link.h-1952-\ntools/include/uapi/linux/if_link.h:1953:#define IFLA_RMNET_MAX\t(__IFLA_RMNET_MAX - 1)\ntools/include/uapi/linux/if_link.h-1954-\n"
} |
| 25/2 | 2026/10/08 01:21 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 46440 output: 53 thoughts: 22 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **RMNET Kconfig Dependency Investigation** Alright, let's get down to brass tacks. I need to quickly ascertain the Kconfig dependencies for RMNET. I'm not going to beat around the bush; I need a clear understanding of its build-time requirements. My primary objective is to map out the interconnectedness, to foresee any potential conflicts or necessary configurations. Let me dive straight into figuring out what exactly RMNET's operational prerequisites are. I need to ensure everything aligns with the current kernel configuration I'm working with. |
| 26/2 | 2026/10/08 01:21 | tool | grepper |
0mArgs:{
"Expression": "RMNET",
"PathPrefixes": [
"drivers/net/ethernet/qualcomm/rmnet/Kconfig",
"drivers/net/ethernet/qualcomm/Kconfig"
]
}Results: {
"Output": "drivers/net/ethernet/qualcomm/rmnet/Kconfig-2-#\ndrivers/net/ethernet/qualcomm/rmnet/Kconfig:3:# RMNET MAP driver\ndrivers/net/ethernet/qualcomm/rmnet/Kconfig-4-#\ndrivers/net/ethernet/qualcomm/rmnet/Kconfig-5-\ndrivers/net/ethernet/qualcomm/rmnet/Kconfig:6:menuconfig RMNET\ndrivers/net/ethernet/qualcomm/rmnet/Kconfig-7-\ttristate \"RmNet MAP driver\"\n--\ndrivers/net/ethernet/qualcomm/rmnet/Kconfig-10-\thelp\ndrivers/net/ethernet/qualcomm/rmnet/Kconfig:11:\t If you select this, you will enable the RMNET module which is used\ndrivers/net/ethernet/qualcomm/rmnet/Kconfig-12-\t for handling data in the multiplexing and aggregation protocol (MAP)\ndrivers/net/ethernet/qualcomm/rmnet/Kconfig:13:\t format in the embedded data path. RMNET devices can be attached to\ndrivers/net/ethernet/qualcomm/rmnet/Kconfig-14-\t any IP mode physical device.\n"
} |
| 27/2 | 2026/10/08 01:21 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 46949 output: 38 thoughts: 18 Thoughts: Here's a summary of my thought process, as requested: **Diving into the Qualcomm Ethernet Configuration** Okay, time to get to the heart of this. My initial thought process is this: I need to understand the configuration options for the Qualcomm Ethernet drivers. My go-to is always the Kconfig file. That's where all the build-time configuration settings are defined. So, my next step is to examine `drivers/net/ethernet/qualcomm/Kconfig`. I expect to find the dependencies, the default values, descriptions, and likely some help text there. This should give me a solid base to understand what features are available and how they are controlled. Let's see what we've got! |
| 28/2 | 2026/10/08 01:22 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/qualcomm/Kconfig",
"FirstLine": 1,
"LineCount": 80
}Results: {
"Contents": " 1:\t# SPDX-License-Identifier: GPL-2.0-only\n 2:\t#\n 3:\t# Qualcomm network device configuration\n 4:\t#\n 5:\t\n 6:\tconfig NET_VENDOR_QUALCOMM\n 7:\t\tbool \"Qualcomm devices\"\n 8:\t\tdefault y\n 9:\t\thelp\n 10:\t\t If you have a network (Ethernet) card belonging to this class, say Y.\n 11:\t\n 12:\t\t Note that the answer to this question doesn't directly affect the\n 13:\t\t kernel: saying N will just cause the configurator to skip all\n 14:\t\t the questions about Qualcomm cards. If you say Y, you will be asked\n 15:\t\t for your specific card in the following questions.\n 16:\t\n 17:\tif NET_VENDOR_QUALCOMM\n 18:\t\n 19:\tconfig QCA7000\n 20:\t\ttristate\n 21:\t\thelp\n 22:\t\t This enables support for the Qualcomm Atheros QCA7000.\n 23:\t\n 24:\tconfig QCA7000_SPI\n 25:\t\ttristate \"Qualcomm Atheros QCA7000 SPI support\"\n 26:\t\tselect QCA7000\n 27:\t\tdepends on SPI_MASTER \u0026\u0026 OF\n 28:\t\thelp\n 29:\t\t This SPI protocol driver supports the Qualcomm Atheros QCA7000.\n 30:\t\n 31:\t\t To compile this driver as a module, choose M here. The module\n 32:\t\t will be called qcaspi.\n 33:\t\n 34:\tconfig QCA7000_UART\n 35:\t\ttristate \"Qualcomm Atheros QCA7000 UART support\"\n 36:\t\tselect QCA7000\n 37:\t\tdepends on SERIAL_DEV_BUS \u0026\u0026 OF\n 38:\t\thelp\n 39:\t\t This UART protocol driver supports the Qualcomm Atheros QCA7000.\n 40:\t\n 41:\t\t Currently the driver assumes these device UART settings:\n 42:\t\t Data bits: 8\n 43:\t\t Parity: None\n 44:\t\t Stop bits: 1\n 45:\t\t Flow control: None\n 46:\t\n 47:\t\t To compile this driver as a module, choose M here. The module\n 48:\t\t will be called qcauart.\n 49:\t\n 50:\tconfig QCOM_EMAC\n 51:\t\ttristate \"Qualcomm EMAC Gigabit Ethernet support\"\n 52:\t\tdepends on HAS_DMA \u0026\u0026 HAS_IOMEM\n 53:\t\tselect CRC32\n 54:\t\tselect PHYLIB\n 55:\t\thelp\n 56:\t\t This driver supports the Qualcomm Technologies, Inc. Gigabit\n 57:\t\t Ethernet Media Access Controller (EMAC). The controller\n 58:\t\t supports IEEE 802.3-2002, half-duplex mode at 10/100 Mb/s,\n 59:\t\t full-duplex mode at 10/100/1000Mb/s, Wake On LAN (WOL) for\n 60:\t\t low power, Receive-Side Scaling (RSS), and IEEE 1588-2008\n 61:\t\t Precision Clock Synchronization Protocol.\n 62:\t\n 63:\tconfig QCOM_PPE\n 64:\t\ttristate \"Qualcomm PPE Ethernet support\"\n 65:\t\tdepends on COMMON_CLK \u0026\u0026 HAS_IOMEM \u0026\u0026 OF\n 66:\t\tdepends on ARCH_QCOM || COMPILE_TEST\n 67:\t\tselect REGMAP_MMIO\n 68:\t\thelp\n 69:\t\t This driver supports the Qualcomm Technologies, Inc. packet\n 70:\t\t process engine (PPE) available with IPQ SoC. The PPE includes\n 71:\t\t the Ethernet MACs, Ethernet DMA (EDMA) and switch core that\n 72:\t\t supports L3 flow offload, L2 switch function, RSS and tunnel\n 73:\t\t offload.\n 74:\t\n 75:\t\t To compile this driver as a module, choose M here. The module\n 76:\t\t will be called qcom-ppe.\n 77:\t\n 78:\tsource \"drivers/net/ethernet/qualcomm/rmnet/Kconfig\"\n 79:\t\n 80:\tendif # NET_VENDOR_QUALCOMM\n"
} |
| 29/2 | 2026/10/08 01:22 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 48292 output: 36 thoughts: 149 Thoughts: **Analyzing the rmnet Driver Configuration** Okay, let's break this down. First, I see that `NET_VENDOR_QUALCOMM` is linked to the location of the rmnet driver's Kconfig file, specifically within the Qualcomm Ethernet driver structure. Diving in, I find that `RMNET` is a menuconfig option within that file, a tristate toggle for the "RmNet MAP driver," which defaults to 'n', meaning it is disabled by default. It also selects `GRO_CELLS`. Now, I need to understand the broader implications. Since `NET_VENDOR_QUALCOMM` is defined in the top-level Ethernet Kconfig, I'll need to investigate that file further. My focus now is on what other configurations or dependencies might impact the enablement of the RMNET driver. I'll search `drivers/net/ethernet/Kconfig` for `NET_VENDOR_QUALCOMM` to see what else it might control or be dependent upon. This should help me get a more complete understanding of its role in the overall Ethernet driver framework and its configuration options. |
| 30/2 | 2026/10/08 01:22 | tool | grepper |
0mError:no matches Args: {
"Expression": "NET_VENDOR_QUALCOMM",
"PathPrefixes": [
"drivers/net/ethernet/Kconfig"
]
}Results: {
"error": "no matches"
} |
| 31/2 | 2026/10/08 01:22 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 48720 output: 26 thoughts: 18 Thoughts: Okay, here's my summary, tailored for an expert audience, as if I'm thinking these thoughts: **Pinpointing the Qualcomm Connection** Alright, time to get laser-focused. My immediate thought is, "Where the heck is `NET_VENDOR_QUALCOMM` defined, or more importantly, *sourced*?" I'm not just looking for a simple declaration; I want to understand its *origins*. Is this a standard header? Is it part of a platform-specific SDK? Is it buried in some obscure build configuration file? Understanding its source is crucial to grasping its implications and how it interacts with the system. Knowing the source will inform any next steps. |
| 32/2 | 2026/10/08 01:22 | tool | grepper |
0mArgs:{
"Expression": "drivers/net/ethernet/qualcomm/Kconfig"
}Results: {
"Output": "drivers/net/ethernet/Kconfig=164=source \"drivers/net/ethernet/brocade/Kconfig\"\ndrivers/net/ethernet/Kconfig:165:source \"drivers/net/ethernet/qualcomm/Kconfig\"\ndrivers/net/ethernet/Kconfig-166-source \"drivers/net/ethernet/rdc/Kconfig\"\n"
} |
| 33/2 | 2026/10/08 01:22 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 49007 output: 35 thoughts: 152 Thoughts: **Analyzing the Configuration Dependencies for Ethernet Driver Code** Okay, so I'm looking at how this Ethernet driver code is configured. I see that `drivers/net/ethernet/Kconfig` is pulled in by `drivers/net/Kconfig`, specifically under the `ETHERNET` section. This means the important configuration options to enable this particular code should be `NET_VENDOR_QUALCOMM` and `RMNET`. That's the baseline. But I need to be thorough. I should double-check to see if there are any other dependencies at the top level, like `INET`, `NET`, `NETDEVICES`, or `ETHERNET` itself, that might indirectly affect this. It’s usually `RMNET` and `NET_VENDOR_QUALCOMM` but better safe than sorry. Wait a second, there's `rmnet_map_data.c`. Could IPv6 come into play here? I need to quickly scan that file for any conditional compilation based on `CONFIG_IPV6`, just to make sure I don't miss something fundamental. Specifically, I'll be looking for any `#ifdef CONFIG_IPV6` or `IS_ENABLED(CONFIG_IPV6)` constructs in that file. That's a good approach to ensure a complete understanding of the necessary configuration. |
| 34/2 | 2026/10/08 01:22 | tool | grepper |
0mArgs:{
"Expression": "CONFIG_",
"PathPrefixes": [
"drivers/net/ethernet/qualcomm/rmnet"
]
}Results: {
"Output": "drivers/net/ethernet/qualcomm/rmnet/Makefile=10=rmnet-y\t\t += rmnet_map_command.o\ndrivers/net/ethernet/qualcomm/rmnet/Makefile:11:obj-$(CONFIG_RMNET) += rmnet.o\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.h-11-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.h:12:#ifndef _RMNET_CONFIG_H_\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.h:13:#define _RMNET_CONFIG_H_\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.h-14-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.h=173=rmnet_get_port_rtnl(const struct net_device *real_dev);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.h:174:#endif /* _RMNET_CONFIG_H_ */\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c=50=rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-138-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:139:#if IS_ENABLED(CONFIG_IPV6)\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-140-static int\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c=222=rmnet_map_ipv4_ul_csum_header(struct iphdr *iphdr,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-240-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:241:#if IS_ENABLED(CONFIG_IPV6)\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-242-static void\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c=284=static void rmnet_map_v5_checksum_uplink_packet(struct sk_buff *skb,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-309-\t\t\ttrans = iph + ip_len;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:310:\t\t} else if (IS_ENABLED(CONFIG_IPV6) \u0026\u0026\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-311-\t\t\t skb-\u003eprotocol == htons(ETH_P_IPV6)) {\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c=466=int rmnet_map_checksum_downlink_packet(struct sk_buff *skb, u16 len)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-492-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:493:\tif (IS_ENABLED(CONFIG_IPV6) \u0026\u0026 skb-\u003eprotocol == htons(ETH_P_IPV6))\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-494-\t\treturn rmnet_map_ipv6_dl_csum_trailer(skb, csum_trailer, priv);\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c=503=static void rmnet_map_v4_checksum_uplink_packet(struct sk_buff *skb,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-533-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:534:\tif (IS_ENABLED(CONFIG_IPV6) \u0026\u0026 skb-\u003eprotocol == htons(ETH_P_IPV6)) {\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-535-\t\trmnet_map_ipv6_ul_csum_header(iphdr, ul_header, skb);\n"
} |
| 35/2 | 2026/10/08 01:22 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 50597 output: 268 thoughts: 2400 Thoughts: **Fuzzing Configuration for Qualcomm RMNET Driver: A Focused Approach** Okay, so we're diving into fuzzing the Qualcomm RMNET driver. The crucial configs are `NET_VENDOR_QUALCOMM` and `RMNET`, and potentially `IPV6`. Given that `WorthFuzzing` should be true, we need a precise `FocusSymbols` list. The goal is to target specific feature logic, avoiding ubiquitous functions. After reviewing the code diff, the following functions warrant inclusion in `FocusSymbols`: * `rmnet_map_process_next_hdr_packet`: This is a *non-static entrypoint* in `rmnet_map_data.c`, crucial for processing coalesced packets. It handles the core logic we need to target. * `rmnet_map_segment_coal_skb`: Core function for coalesced packet segmentation. * `__rmnet_map_segment_coal_skb`: Segment reconstruction. * `rmnet_map_coal_validate_bounds`: Handles bounds validation for Number of Link Objects (NLOs) - important for error conditions. * `rmnet_map_data_check_coal_header`: Validates the coalesce header, a critical point for potentially malformed data. * `rmnet_map_coal_gro_fast_path`: Provides GRO fast-path delivery, an optimization which also needs to be validated. * `rmnet_vnd_update_dev_mtu`: Handles MTU updates. This is a modified piece of logic we must validate. * `rmnet_newlink`: rtnl link operations creation. * `rmnet_changelink`: rtnl link operations change. We need to be sure to check that static functions in .c files are *not* inlined by the compiler. These will be distinct symbols! This contrasts with the case of static inlines defined in headers. I have confirmed that the listed symbols are correctly identifiable. `WorthFuzzing` is unequivocally `true`. The RMNET driver is reachable via standard QEMU with virtual interfaces. This code introduces significant complexity with packet coalescing, segmentation, header validation, memory handling, checksum manipulation, GSO, bounds checks, etc. These areas are reachable through user-injected packets and netlink operations, making this code a prime target for fuzzing to look for memory safety issues or logic errors. Let's double-check all requirements: * `EnableConfigs`: `["NET_VENDOR_QUALCOMM", "RMNET"]` * `FocusSymbols`: Specific symbols listed above * `WorthFuzzing`: `true` And for the reasoning: * The RMNet driver implements the Multiplexing and Aggregation Protocol (MAP), working with any network interface. * The patch adds MAPv5 downlink hardware packet coalescing/segmentation logic. This is the new, complex logic that we want to target. * This logic is reachable via user-injected packets and netlink operations. Everything checks out. We are now ready to generate the fuzzing config. |
| 36/2 | 2026/10/08 01:22 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"NET_VENDOR_QUALCOMM",
"RMNET"
],
"FocusSymbols": [
"rmnet_map_process_next_hdr_packet",
"rmnet_map_segment_coal_skb",
"__rmnet_map_segment_coal_skb",
"rmnet_map_coal_validate_bounds",
"rmnet_map_data_check_coal_header",
"rmnet_map_coal_gro_fast_path",
"rmnet_vnd_update_dev_mtu",
"rmnet_newlink"
],
"Reasoning": "The patch adds MAPv5 downlink packet coalescing and de-aggregation support to Qualcomm's rmnet driver. RMNet is an rtnl virtual netlink device (kind \"rmnet\") that can attach to any underlying network interface (including virtual devices such as dummy or veth) without dedicated physical hardware. Ingress packets can be delivered from userspace through the base interface to exercise the new frame parsing, NLO validation, checksum verification, skb reallocation, and GSO segment construction logic. This complex network packet manipulation is fully reachable in virtualized fuzzing environments.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"NET_VENDOR_QUALCOMM",
"RMNET"
],
"FocusSymbols": [
"rmnet_map_process_next_hdr_packet",
"rmnet_map_segment_coal_skb",
"__rmnet_map_segment_coal_skb",
"rmnet_map_coal_validate_bounds",
"rmnet_map_data_check_coal_header",
"rmnet_map_coal_gro_fast_path",
"rmnet_vnd_update_dev_mtu",
"rmnet_newlink"
],
"Reasoning": "The patch adds MAPv5 downlink packet coalescing and de-aggregation support to Qualcomm's rmnet driver. RMNet is an rtnl virtual netlink device (kind \"rmnet\") that can attach to any underlying network interface (including virtual devices such as dummy or veth) without dedicated physical hardware. Ingress packets can be delivered from userspace through the base interface to exercise the new frame parsing, NLO validation, checksum verification, skb reallocation, and GSO segment construction logic. This complex network packet manipulation is fully reachable in virtualized fuzzing environments.",
"WorthFuzzing": true
} |
| 37/1 | 2026/10/08 01:22 | action | If |
5mArgs:{
"WorthFuzzing": true
}Results: null |
| 38/2 | 2026/10/08 01:22 | agent | kmsan-evaluator |
5mModel:core Args: null Results: {
"KMSANReasoning": "The patch series implements MAPv5 packet coalescing support and per-CPU diagnostic statistics for the Qualcomm rmnet driver.\n\nKASAN vs KMSAN applicability:\n- Potential risks introduced by these changes center around incoming packet parsing: decoding Number-Length Object (NLO) headers, calculating packet boundaries, reconstructing logical segments from coalesced frames, and manipulating SKB headroom/tailroom. Any bugs in these areas (such as buffer over-reads or out-of-bounds pointer arithmetic on malformed network packets) are out-of-bounds accesses detected by KASAN.\n- KMSAN is not justified here because there are no uninitialized memory risks:\n 1. All new or modified stack variables (e.g., `struct rmnet_map_coal_metadata coal_meta`, `struct rmnet_priv_stats total_stats`) are explicitly zero-initialized via `memset()` or `{ }`.\n 2. Out-parameters in helper functions (e.g., `rmnet_map_data_check_coal_header`) are unconditionally populated on success and callers abort on error before consuming them.\n 3. Statistics reported to userspace or netlink/ethtool (`rmnet_get_ethtool_stats`, `rmnet_get_stats64`, and `rmnet_get_queue_stats_rx`) are aggregated into zero-initialized structures; the ethtool buffer length matches the field count without padding gaps.\n 4. Per-CPU statistics structures are allocated with `alloc_percpu()` (which zeroes memory).\n 5. Segment SKBs allocated via `alloc_skb()` are completely filled with payload and restored headers via `skb_put_data()`, `skb_push()`, and `memcpy()`, leaving no uninitialized data bytes.\n\nBecause the risks are bounded to buffer boundaries and logic validation (monitored by KASAN) and no uninitialized memory or info-leak vectors are introduced, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false
}Instruction: You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.
CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
a comprehensive suite of debugging tools and sanitizers, including KASAN
(out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
(locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
or page allocations) and kernel-to-user memory info-leaks.
Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.
Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.
Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
attributes, ioctl output arguments, socket options, or BPF buffers) where fields
or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
uninitialized bytes of existing buffers.
Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
dereferences, locking deadlocks, or use-after-free bugs (these are already caught
by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.
Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit 5f934836a3da604812716de3e50f9bc46f6de000
Author: syz-cluster <triage@syzkaller.com>
Date: Thu Oct 8 01:20:03 2026 +0000
syz-cluster: applied patch under review
diff --git a/Documentation/networking/device_drivers/cellular/qualcomm/rmnet.rst b/Documentation/networking/device_drivers/cellular/qualcomm/rmnet.rst
index 5aedbabb73827..52f92d2fba311 100644
--- a/Documentation/networking/device_drivers/cellular/qualcomm/rmnet.rst
+++ b/Documentation/networking/device_drivers/cellular/qualcomm/rmnet.rst
@@ -125,8 +125,8 @@ Command (1)/ Data (0) bit value is to indicate if the packet is a MAP command
or data packet. Command packet is used for transport level flow control. Data
packets are standard IP packets.
-Next header is used to indicate the presence of another header, currently is
-limited to checksum header.
+Next header is used to indicate the presence of another header, currently
+limited to the checksum and coalescing headers.
Padding is the number of bytes to be appended to the payload to
ensure 4 byte alignment.
@@ -150,11 +150,11 @@ Header Type is to indicate the type of header, this usually is set to CHECKSUM
Header types
-= ===============
+= ======================
0 Reserved
-1 Reserved
+1 coalescing header
2 checksum header
-= ===============
+= ======================
Checksum Valid is to indicate whether the header checksum is valid. Value of 1
implies that checksum is calculated on this packet and is valid, value of 0
@@ -162,8 +162,109 @@ indicates that the calculated packet checksum is invalid.
Reserved bits must be zero when sent and ignored when received.
-e. MAP packet v1/v5 (command specific)
---------------------------------------
+e. Coalescing header v5
+------------------------
+
+Hardware can coalesce multiple same-flow IP packets into a single MAP frame
+to reduce per-packet overhead at high data rates. Packets are grouped into
+NLOs, with all packets in each NLO having the same length. The coalescing
+header (header type 1) describes the coalesced content.
+
+Packet format::
+
+ Bit 0 - 6 7 8 9-11 12-15
+ Function Header Type Next Header CSUM valid Num NLOs (reserved)
+
+ Bit 16-19 20-23
+ Function Close value Close type
+
+ Bit 24-27 28-31
+ Function (reserved) VEID
+
+ Bit 32 - 47 48 - 55 56 - 63
+ Function Packet length CSUM error bitmap Num packets (NLO 0)
+
+ ... (up to 6 NLO entries total, same 32-bit format per entry)
+
+Header Type is set to 1 (coalescing).
+
+The MAP header ``pkt_len`` includes the coalescing header, coalesced packet
+data, and any MAP padding.
+
+Num NLOs (Number-Length Objects) is the count of active NLO entries
+(1 – 6). Each NLO describes a group of consecutive coalesced packets
+that all share the same IP packet length.
+
+Num NLOs identifies the active prefix of the six NLO slots. The header
+always contains all six slots and remains 28 bytes long regardless of Num
+NLOs. A slot with ``num_packets == 0`` ends the active NLO prefix. The
+full coalescing header is included in the MAP header's ``pkt_len``.
+
+Some hardware may report Num NLOs incorrectly. For compatibility, receivers
+should derive the active prefix from ``num_packets`` when needed. This
+requires unused slots to have ``num_packets == 0``.
+
+CSUM valid (bit 8) is a frame-level indication that the hardware checksum is
+valid for all packets in the frame. It is distinct from the per-packet CSUM
+error bitmap in each NLO entry.
+
+For a single-NLO, single-packet frame, CSUM valid must not be trusted when
+the close reason is a FIN/PSH close, a packet limit, a byte limit, or a time
+limit. In these cases, the rmnet driver treats the packet checksum as
+unverified and lets the network stack validate it instead of relying on the
+coalescing checksum indications.
+IPv4 UDP packets with a zero checksum remain valid because that checksum is
+optional.
+
+Close type and close value encode the hardware reason that coalescing
+was terminated for this frame:
+
+Close type values:
+
+= ==============================
+0 non-coalesced (single packet)
+1 IP flow miss
+2 transport flow miss
+3 hardware limit (see value)
+4 coalescing closed (FIN/PSH)
+= ==============================
+
+Close value (used when close type is 3):
+
+= ==================
+0 NL limit reached
+1 packet limit
+2 byte limit
+3 time limit
+4 eviction
+= ==================
+
+VEID is the virtual endpoint ID of the originating flow.
+
+Each NLO entry::
+
+ Bit 0 - 15 16 - 23 24 - 31
+ Function Pkt length CSUM error bitmap Num packets
+
+Pkt length is the full IP packet length, including the IP header, transport
+header, and payload, for every packet in this NLO group. The IP and transport
+headers are present once in the coalesced frame and are not repeated for each
+packet.
+
+CSUM error bitmap is one 48-bit stream formed by concatenating the
+``csum_error_bitmap`` bytes from all six NLO slots in slot order. Packet 0
+corresponds to bit 0 of slot 0's bitmap byte, and bits are consumed from
+least significant bit to most significant bit. The bit stream is indexed by
+the packet's absolute position in the frame and does not restart at an NLO
+boundary. If an NLO contains more than eight packets, its error bits
+continue into the bitmap byte of the following slot. Bitmap bytes in slots
+after the active NLO prefix may therefore contain continuation bits and must
+not be ignored.
+
+Num packets is the count of coalesced packets described by this NLO.
+
+f. MAP packet v1/v5 (command specific)
+---------------------------------------
Packet format::
@@ -187,7 +288,7 @@ Command types
3 is for error during processing of commands
= ==========================================
-f. Aggregation
+g. Aggregation
--------------
Aggregation is multiple MAP packets (can be data or command) delivered to
@@ -208,3 +309,39 @@ rmnet userspace configuration is done through netlink using iproute2
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/
The driver uses rtnl_link_ops for communication.
+
+The data format flags controlling the ingress and egress processing
+pipeline are set via the ``IFLA_RMNET_FLAGS`` attribute
+(``struct ifla_rmnet_flags``).
+
+Relevant ingress flags:
+
+``RMNET_FLAGS_INGRESS_DEAGGREGATION``
+ Enable MAP frame de-aggregation.
+
+``RMNET_FLAGS_INGRESS_MAP_CKSUMV4``
+ Enable MAPv4 downlink checksum offload.
+
+``RMNET_FLAGS_INGRESS_MAP_CKSUMV5``
+ Enable MAPv5 downlink checksum offload (header type 2).
+
+``RMNET_FLAGS_INGRESS_COALESCE``
+ Enable MAPv5 downlink hardware coalescing (header type 1).
+ This flag requires ``RMNET_FLAGS_INGRESS_MAP_CKSUMV5``. MAPv4 and
+ MAPv5 checksum flags cannot be enabled together in either direction.
+ A direction may leave checksum offload disabled. Invalid combinations
+ are rejected.
+ When RX checksum offload and ``rx-gro-hw`` are enabled, valid
+ multi-packet coalesced frames can be delivered as batched GSO SKBs.
+ Otherwise, multi-packet coalesced frames are rejected. A coalesced frame
+ containing one packet is delivered as a normal non-GSO skb. IP options,
+ IPv6 extension headers, and zero-payload packets can also prevent GSO
+ processing for a frame.
+
+Relevant egress flags:
+
+``RMNET_FLAGS_EGRESS_MAP_CKSUMV4``
+ Enable MAPv4 uplink checksum offload.
+
+``RMNET_FLAGS_EGRESS_MAP_CKSUMV5``
+ Enable MAPv5 uplink checksum offload.
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
index 61b04c6c0390e..ec882ad371ab7 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
@@ -26,6 +26,31 @@ static int rmnet_is_real_dev_registered(const struct net_device *real_dev)
return rcu_access_pointer(real_dev->rx_handler) == rmnet_rx_handler;
}
+/* Only three MAP configurations are supported: MAPv1 (no checksum
+ * offload), MAPv4 (v4 checksum offload) and MAPv5 (v5 checksum
+ * offload). MAP command support is orthogonal and permitted with any
+ * of the three. Checksum offload versions are selected independently
+ * for ingress and egress, but only one version may be enabled across
+ * the device. Mixing v4 and v5 checksum flags is not supported. DL
+ * packet coalescing additionally requires a MAPv5 configuration.
+ */
+static bool rmnet_config_data_format_valid(u32 data_format)
+{
+ u32 v4_mask = RMNET_FLAGS_INGRESS_MAP_CKSUMV4 |
+ RMNET_FLAGS_EGRESS_MAP_CKSUMV4;
+ u32 v5_mask = RMNET_FLAGS_INGRESS_MAP_CKSUMV5 |
+ RMNET_FLAGS_EGRESS_MAP_CKSUMV5;
+
+ if ((data_format & v4_mask) && (data_format & v5_mask))
+ return false;
+
+ if ((data_format & RMNET_FLAGS_INGRESS_COALESCE) &&
+ !(data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV5))
+ return false;
+
+ return true;
+}
+
/* Needs rtnl lock */
struct rmnet_port*
rmnet_get_port_rtnl(const struct net_device *real_dev)
@@ -143,6 +168,20 @@ static int rmnet_newlink(struct net_device *dev,
return -ENODEV;
}
+ if (data[IFLA_RMNET_FLAGS]) {
+ struct ifla_rmnet_flags *flags;
+
+ flags = nla_data(data[IFLA_RMNET_FLAGS]);
+ data_format &= ~flags->mask;
+ data_format |= flags->flags & flags->mask;
+ }
+
+ if (!rmnet_config_data_format_valid(data_format)) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "unsupported MAP checksum flag combination");
+ return -EINVAL;
+ }
+
ep = kzalloc_obj(*ep);
if (!ep)
return -ENOMEM;
@@ -154,7 +193,8 @@ static int rmnet_newlink(struct net_device *dev,
goto err0;
port = rmnet_get_port_rtnl(real_dev);
- err = rmnet_vnd_newlink(mux_id, dev, port, real_dev, ep, extack);
+ err = rmnet_vnd_newlink(mux_id, dev, port, real_dev, ep, extack,
+ data_format);
if (err)
goto err1;
@@ -162,24 +202,23 @@ static int rmnet_newlink(struct net_device *dev,
if (err < 0)
goto err2;
+ /* Update existing MTUs before publishing the shared data format. */
+ err = rmnet_vnd_update_dev_mtu(port, real_dev, data_format);
+ if (err)
+ goto err3;
+
port->rmnet_mode = mode;
port->rmnet_dev = dev;
hlist_add_head_rcu(&ep->hlnode, &port->muxed_ep[mux_id]);
- if (data[IFLA_RMNET_FLAGS]) {
- struct ifla_rmnet_flags *flags;
-
- flags = nla_data(data[IFLA_RMNET_FLAGS]);
- data_format &= ~flags->mask;
- data_format |= flags->flags & flags->mask;
- }
-
netdev_dbg(dev, "data format [0x%08X]\n", data_format);
WRITE_ONCE(port->data_format, data_format);
return 0;
+err3:
+ netdev_upper_dev_unlink(real_dev, dev);
err2:
unregister_netdevice(dev);
rmnet_vnd_dellink(mux_id, port, ep);
@@ -301,9 +340,13 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],
struct netlink_ext_ack *extack)
{
struct rmnet_priv *priv = netdev_priv(dev);
+ struct ifla_rmnet_flags *flags;
struct net_device *real_dev;
struct rmnet_port *port;
+ u32 old_data_format;
+ u32 data_format;
u16 mux_id;
+ int err;
if (!dev)
return -ENODEV;
@@ -320,6 +363,19 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],
port = rmnet_get_port_rtnl(real_dev);
+ if (data[IFLA_RMNET_FLAGS]) {
+ old_data_format = READ_ONCE(port->data_format);
+ flags = nla_data(data[IFLA_RMNET_FLAGS]);
+ data_format = old_data_format & ~flags->mask;
+ data_format |= flags->flags & flags->mask;
+
+ if (!rmnet_config_data_format_valid(data_format)) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "unsupported MAP checksum flag combination");
+ return -EINVAL;
+ }
+ }
+
if (data[IFLA_RMNET_MUX_ID]) {
mux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]);
@@ -346,21 +402,13 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],
}
if (data[IFLA_RMNET_FLAGS]) {
- struct ifla_rmnet_flags *flags;
- u32 old_data_format;
- u32 data_format;
-
- old_data_format = port->data_format;
- flags = nla_data(data[IFLA_RMNET_FLAGS]);
- data_format = old_data_format & ~flags->mask;
- data_format |= flags->flags & flags->mask;
- WRITE_ONCE(port->data_format, data_format);
-
- if (rmnet_vnd_update_dev_mtu(port, real_dev)) {
- WRITE_ONCE(port->data_format, old_data_format);
+ err = rmnet_vnd_update_dev_mtu(port, real_dev, data_format);
+ if (err) {
NL_SET_ERR_MSG_MOD(extack, "Invalid MTU on real dev");
- return -EINVAL;
+ return err;
}
+
+ WRITE_ONCE(port->data_format, data_format);
}
return 0;
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h
index 5adda0323dda7..c71587c843e47 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h
@@ -63,12 +63,14 @@ struct rmnet_vnd_stats {
u32 tx_drops;
};
-struct rmnet_pcpu_stats {
- struct rmnet_vnd_stats stats;
- struct u64_stats_sync syncp;
-};
-
struct rmnet_priv_stats {
+ /* Network stack RX statistics for all rmnet receive paths */
+ u64 rx_hw_gro_packets;
+ u64 rx_hw_gro_wire_packets;
+ u64 rx_alloc_fail;
+ u64 rx_dropped;
+
+ /* Custom diagnostics for the coalescing receive path */
u64 csum_ok;
u64 csum_ip4_header_bad;
u64 csum_valid_unset;
@@ -80,6 +82,77 @@ struct rmnet_priv_stats {
u64 csum_skipped;
u64 csum_sw;
u64 csum_hw;
+ /* Coalescing-only counters. Some are subsets of the standard counters. */
+ u64 coal_alloc_fail;
+ u64 coal_rx;
+ u64 coal_pkts;
+ u64 coal_hdr_err;
+ u64 coal_hdr_pkt_err;
+ u64 coal_bounds_err;
+ u64 coal_csum_err;
+ u64 coal_csum_drop;
+ u64 coal_reconstruct;
+ u64 coal_ip_invalid;
+ u64 coal_trans_invalid;
+ /* close-reason sub-counters */
+ u64 coal_close_non_coal;
+ u64 coal_close_ip_miss;
+ u64 coal_close_trans_miss;
+ u64 coal_close_hw_nl;
+ u64 coal_close_hw_pkt;
+ u64 coal_close_hw_byte;
+ u64 coal_close_hw_time;
+ u64 coal_close_hw_evict;
+ u64 coal_close_coal;
+};
+
+struct rmnet_pcpu_priv_stats {
+ /* Network stack RX statistics for all rmnet receive paths */
+ u64_stats_t rx_hw_gro_packets;
+ u64_stats_t rx_hw_gro_wire_packets;
+ u64_stats_t rx_alloc_fail;
+ u64_stats_t rx_dropped;
+
+ /* Custom diagnostics for the coalescing receive path */
+ u64_stats_t csum_ok;
+ u64_stats_t csum_ip4_header_bad;
+ u64_stats_t csum_valid_unset;
+ u64_stats_t csum_validation_failed;
+ u64_stats_t csum_err_bad_buffer;
+ u64_stats_t csum_err_invalid_ip_version;
+ u64_stats_t csum_err_invalid_transport;
+ u64_stats_t csum_fragmented_pkt;
+ u64_stats_t csum_skipped;
+ u64_stats_t csum_sw;
+ u64_stats_t csum_hw;
+ /* Coalescing-only counters. Some are subsets of the standard counters. */
+ u64_stats_t coal_alloc_fail;
+ u64_stats_t coal_rx;
+ u64_stats_t coal_pkts;
+ u64_stats_t coal_hdr_err;
+ u64_stats_t coal_hdr_pkt_err;
+ u64_stats_t coal_bounds_err;
+ u64_stats_t coal_csum_err;
+ u64_stats_t coal_csum_drop;
+ u64_stats_t coal_reconstruct;
+ u64_stats_t coal_ip_invalid;
+ u64_stats_t coal_trans_invalid;
+ /* close-reason sub-counters */
+ u64_stats_t coal_close_non_coal;
+ u64_stats_t coal_close_ip_miss;
+ u64_stats_t coal_close_trans_miss;
+ u64_stats_t coal_close_hw_nl;
+ u64_stats_t coal_close_hw_pkt;
+ u64_stats_t coal_close_hw_byte;
+ u64_stats_t coal_close_hw_time;
+ u64_stats_t coal_close_hw_evict;
+ u64_stats_t coal_close_coal;
+};
+
+struct rmnet_pcpu_stats {
+ struct rmnet_vnd_stats stats;
+ struct rmnet_pcpu_priv_stats priv_stats;
+ struct u64_stats_sync syncp;
};
struct rmnet_priv {
@@ -87,7 +160,6 @@ struct rmnet_priv {
struct net_device *real_dev;
struct rmnet_pcpu_stats __percpu *pcpu_stats;
struct gro_cells gro_cells;
- struct rmnet_priv_stats stats;
};
struct rmnet_port *rmnet_get_port_rcu(const struct net_device *real_dev);
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c
index aa5523f4618eb..bb867ceb01c1c 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c
@@ -50,6 +50,16 @@ rmnet_deliver_skb(struct sk_buff *skb)
gro_cells_receive(&priv->gro_cells, skb);
}
+static void rmnet_deliver_skb_list(struct sk_buff_head *head)
+{
+ struct sk_buff *skb;
+
+ while ((skb = __skb_dequeue(head))) {
+ rmnet_set_skb_proto(skb);
+ rmnet_deliver_skb(skb);
+ }
+}
+
/* MAP handler */
static void
@@ -59,6 +69,7 @@ __rmnet_map_ingress_handler(struct sk_buff *skb,
{
struct rmnet_map_header *map_header = (void *)skb->data;
struct rmnet_endpoint *ep;
+ struct sk_buff_head list;
u16 len, pad;
u8 mux_id;
@@ -83,12 +94,13 @@ __rmnet_map_ingress_handler(struct sk_buff *skb,
skb->dev = ep->egress_dev;
- if ((data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV5) &&
+ __skb_queue_head_init(&list);
+
+ if ((data_format &
+ (RMNET_FLAGS_INGRESS_MAP_CKSUMV5 | RMNET_FLAGS_INGRESS_COALESCE)) &&
(map_header->flags & MAP_NEXT_HEADER_FLAG)) {
- if (rmnet_map_process_next_hdr_packet(skb, len))
+ if (rmnet_map_process_next_hdr_packet(skb, &list, len, data_format))
goto free_skb;
- skb_pull(skb, sizeof(*map_header));
- rmnet_set_skb_proto(skb);
} else {
/* Subtract MAP header */
skb_pull(skb, sizeof(*map_header));
@@ -96,10 +108,11 @@ __rmnet_map_ingress_handler(struct sk_buff *skb,
if (data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV4 &&
!rmnet_map_checksum_downlink_packet(skb, len + pad))
skb->ip_summed = CHECKSUM_UNNECESSARY;
+ skb_trim(skb, len);
+ __skb_queue_tail(&list, skb);
}
- skb_trim(skb, len);
- rmnet_deliver_skb(skb);
+ rmnet_deliver_skb_list(&list);
return;
free_skb:
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h
index 0977e495f5915..77ddac6023c01 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h
@@ -6,6 +6,22 @@
#define _RMNET_MAP_H_
#include <linux/if_rmnet.h>
+enum rmnet_map_v5_close_type {
+ RMNET_MAP_COAL_CLOSE_NON_COAL,
+ RMNET_MAP_COAL_CLOSE_IP_MISS,
+ RMNET_MAP_COAL_CLOSE_TRANS_MISS,
+ RMNET_MAP_COAL_CLOSE_HW,
+ RMNET_MAP_COAL_CLOSE_COAL,
+};
+
+enum rmnet_map_v5_close_value {
+ RMNET_MAP_COAL_CLOSE_HW_NL,
+ RMNET_MAP_COAL_CLOSE_HW_PKT,
+ RMNET_MAP_COAL_CLOSE_HW_BYTE,
+ RMNET_MAP_COAL_CLOSE_HW_TIME,
+ RMNET_MAP_COAL_CLOSE_HW_EVICT,
+};
+
struct rmnet_map_control_command {
u8 command_name;
u8 cmd_type:2;
@@ -53,7 +69,9 @@ void rmnet_map_checksum_uplink_packet(struct sk_buff *skb,
struct rmnet_port *port,
struct net_device *orig_dev,
int csum_type);
-int rmnet_map_process_next_hdr_packet(struct sk_buff *skb, u16 len);
+int rmnet_map_process_next_hdr_packet(struct sk_buff *skb,
+ struct sk_buff_head *list,
+ u16 len, u32 data_format);
unsigned int rmnet_map_tx_aggregate(struct sk_buff *skb, struct rmnet_port *port,
struct net_device *orig_dev);
void rmnet_map_tx_aggregate_init(struct rmnet_port *port);
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
index 39d6d084e73f0..74d64b7066e2b 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
@@ -7,7 +7,11 @@
#include <linux/netdevice.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
+#include <linux/tcp.h>
+#include <linux/udp.h>
+#include <net/ip.h>
#include <net/ip6_checksum.h>
+#include <net/ipv6.h>
#include <linux/bitfield.h>
#include "rmnet_config.h"
#include "rmnet_map.h"
@@ -17,6 +21,19 @@
#define RMNET_MAP_DEAGGR_SPACING 64
#define RMNET_MAP_DEAGGR_HEADROOM (RMNET_MAP_DEAGGR_SPACING / 2)
+struct rmnet_map_coal_metadata {
+ void *ip_header;
+ void *trans_header;
+ u16 ip_len;
+ u16 trans_len;
+ u16 data_offset;
+ u16 data_len;
+ u8 ip_proto;
+ u8 trans_proto;
+ u8 pkt_count;
+ bool zero_csum;
+};
+
static __sum16 *rmnet_map_get_csum_field(unsigned char protocol,
const void *txporthdr)
{
@@ -36,34 +53,45 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb,
{
struct iphdr *ip4h = (struct iphdr *)skb->data;
void *txporthdr = skb->data + ip4h->ihl * 4;
+ struct rmnet_pcpu_stats *pcpu_ptr;
__sum16 *csum_field, pseudo_csum;
__sum16 ip_payload_csum;
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
+
/* Computing the checksum over just the IPv4 header--including its
* checksum field--should yield 0. If it doesn't, the IP header
* is bad, so return an error and let the IP layer drop it.
*/
if (ip_fast_csum(ip4h, ip4h->ihl)) {
- priv->stats.csum_ip4_header_bad++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_ip4_header_bad);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return -EINVAL;
}
/* We don't support checksum offload on IPv4 fragments */
if (ip_is_fragment(ip4h)) {
- priv->stats.csum_fragmented_pkt++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_fragmented_pkt);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return -EOPNOTSUPP;
}
/* Checksum offload is only supported for UDP and TCP protocols */
csum_field = rmnet_map_get_csum_field(ip4h->protocol, txporthdr);
if (!csum_field) {
- priv->stats.csum_err_invalid_transport++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_err_invalid_transport);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return -EPROTONOSUPPORT;
}
/* RFC 768: UDP checksum is optional for IPv4, and is 0 if unused */
if (!*csum_field && ip4h->protocol == IPPROTO_UDP) {
- priv->stats.csum_skipped++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_skipped);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return 0;
}
@@ -96,11 +124,15 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb,
/* The cast is required to ensure only the low 16 bits are examined */
if (ip_payload_csum != (__sum16)~pseudo_csum) {
- priv->stats.csum_validation_failed++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_validation_failed);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return -EINVAL;
}
- priv->stats.csum_ok++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_ok);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return 0;
}
@@ -112,16 +144,21 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb,
{
struct ipv6hdr *ip6h = (struct ipv6hdr *)skb->data;
void *txporthdr = skb->data + sizeof(*ip6h);
+ struct rmnet_pcpu_stats *pcpu_ptr;
__sum16 *csum_field, pseudo_csum;
__sum16 ip6_payload_csum;
__be16 ip_header_csum;
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
+
/* Checksum offload is only supported for UDP and TCP protocols;
* the packet cannot include any IPv6 extension headers
*/
csum_field = rmnet_map_get_csum_field(ip6h->nexthdr, txporthdr);
if (!csum_field) {
- priv->stats.csum_err_invalid_transport++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_err_invalid_transport);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return -EPROTONOSUPPORT;
}
@@ -147,11 +184,15 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb,
* examined.
*/
if (ip6_payload_csum != (__sum16)~pseudo_csum) {
- priv->stats.csum_validation_failed++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_validation_failed);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return -EINVAL;
}
- priv->stats.csum_ok++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_ok);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return 0;
}
#else
@@ -246,6 +287,9 @@ static void rmnet_map_v5_checksum_uplink_packet(struct sk_buff *skb,
{
struct rmnet_priv *priv = netdev_priv(orig_dev);
struct rmnet_map_v5_csum_header *ul_header;
+ struct rmnet_pcpu_stats *pcpu_ptr;
+
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
ul_header = skb_push(skb, sizeof(*ul_header));
memset(ul_header, 0, sizeof(*ul_header));
@@ -270,7 +314,9 @@ static void rmnet_map_v5_checksum_uplink_packet(struct sk_buff *skb,
proto = ((struct ipv6hdr *)iph)->nexthdr;
trans = iph + ip_len;
} else {
- priv->stats.csum_err_invalid_ip_version++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_err_invalid_ip_version);
+ u64_stats_update_end(&pcpu_ptr->syncp);
goto sw_csum;
}
@@ -279,13 +325,17 @@ static void rmnet_map_v5_checksum_uplink_packet(struct sk_buff *skb,
skb->ip_summed = CHECKSUM_NONE;
/* Ask for checksum offloading */
ul_header->csum_info |= MAPV5_CSUMINFO_VALID_FLAG;
- priv->stats.csum_hw++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_hw);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return;
}
}
sw_csum:
- priv->stats.csum_sw++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_sw);
+ u64_stats_update_end(&pcpu_ptr->syncp);
}
/* Adds MAP header to front of skb->data
@@ -337,8 +387,8 @@ u32 rmnet_map_validate_packet_len(struct sk_buff *skb, u32 data_format)
{
struct rmnet_map_v5_csum_header *next_hdr = NULL;
struct rmnet_map_header *maph;
- void *data = skb->data;
u32 packet_len;
+ u8 hdr_type;
if (skb->len < sizeof(*maph))
return 0;
@@ -353,24 +403,28 @@ u32 rmnet_map_validate_packet_len(struct sk_buff *skb, u32 data_format)
if (data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV4) {
packet_len += sizeof(struct rmnet_map_dl_csum_trailer);
- } else if ((data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV5) &&
+ } else if ((data_format &
+ (RMNET_FLAGS_INGRESS_MAP_CKSUMV5 | RMNET_FLAGS_INGRESS_COALESCE)) &&
!(maph->flags & MAP_CMD_FLAG)) {
- /* Mapv5 data pkt without csum hdr is invalid */
if (!(maph->flags & MAP_NEXT_HEADER_FLAG))
return 0;
- packet_len += sizeof(*next_hdr);
- next_hdr = data + sizeof(*maph);
+ if (skb->len < sizeof(*maph) + sizeof(*next_hdr))
+ return 0;
+
+ next_hdr = (struct rmnet_map_v5_csum_header *)(skb->data + sizeof(*maph));
+ hdr_type = u8_get_bits(next_hdr->header_info,
+ MAPV5_HDRINFO_HDR_TYPE_FMASK);
+
+ if (hdr_type == RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD)
+ packet_len += sizeof(*next_hdr);
+ else if (hdr_type != RMNET_MAP_HEADER_TYPE_COALESCING)
+ return 0;
}
if (skb->len < packet_len)
return 0;
- if (next_hdr &&
- u8_get_bits(next_hdr->header_info, MAPV5_HDRINFO_HDR_TYPE_FMASK) !=
- RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD)
- return 0;
-
return packet_len;
}
@@ -413,16 +467,23 @@ int rmnet_map_checksum_downlink_packet(struct sk_buff *skb, u16 len)
{
struct rmnet_priv *priv = netdev_priv(skb->dev);
struct rmnet_map_dl_csum_trailer *csum_trailer;
+ struct rmnet_pcpu_stats *pcpu_ptr;
+
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
if (unlikely(!(skb->dev->features & NETIF_F_RXCSUM))) {
- priv->stats.csum_sw++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_sw);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return -EOPNOTSUPP;
}
csum_trailer = (struct rmnet_map_dl_csum_trailer *)(skb->data + len);
if (!(csum_trailer->flags & MAP_CSUM_DL_VALID_FLAG)) {
- priv->stats.csum_valid_unset++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_valid_unset);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return -EINVAL;
}
@@ -432,7 +493,9 @@ int rmnet_map_checksum_downlink_packet(struct sk_buff *skb, u16 len)
if (IS_ENABLED(CONFIG_IPV6) && skb->protocol == htons(ETH_P_IPV6))
return rmnet_map_ipv6_dl_csum_trailer(skb, csum_trailer, priv);
- priv->stats.csum_err_invalid_ip_version++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_err_invalid_ip_version);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return -EPROTONOSUPPORT;
}
@@ -442,8 +505,11 @@ static void rmnet_map_v4_checksum_uplink_packet(struct sk_buff *skb,
{
struct rmnet_priv *priv = netdev_priv(orig_dev);
struct rmnet_map_ul_csum_header *ul_header;
+ struct rmnet_pcpu_stats *pcpu_ptr;
void *iphdr;
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
+
ul_header = (struct rmnet_map_ul_csum_header *)
skb_push(skb, sizeof(struct rmnet_map_ul_csum_header));
@@ -459,22 +525,30 @@ static void rmnet_map_v4_checksum_uplink_packet(struct sk_buff *skb,
if (skb->protocol == htons(ETH_P_IP)) {
rmnet_map_ipv4_ul_csum_header(iphdr, ul_header, skb);
- priv->stats.csum_hw++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_hw);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return;
}
if (IS_ENABLED(CONFIG_IPV6) && skb->protocol == htons(ETH_P_IPV6)) {
rmnet_map_ipv6_ul_csum_header(iphdr, ul_header, skb);
- priv->stats.csum_hw++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_hw);
+ u64_stats_update_end(&pcpu_ptr->syncp);
return;
}
- priv->stats.csum_err_invalid_ip_version++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_err_invalid_ip_version);
+ u64_stats_update_end(&pcpu_ptr->syncp);
sw_csum:
memset(ul_header, 0, sizeof(*ul_header));
- priv->stats.csum_sw++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_sw);
+ u64_stats_update_end(&pcpu_ptr->syncp);
}
/* Generates UL checksum meta info header for IPv4 and IPv6 over TCP and UDP
@@ -497,34 +571,847 @@ void rmnet_map_checksum_uplink_packet(struct sk_buff *skb,
}
}
-/* Process a MAPv5 packet header */
-int rmnet_map_process_next_hdr_packet(struct sk_buff *skb,
- u16 len)
+static struct rmnet_map_v5_csum_header *
+rmnet_map_get_next_hdr(struct sk_buff *skb)
{
- struct rmnet_priv *priv = netdev_priv(skb->dev);
- struct rmnet_map_v5_csum_header *next_hdr;
- u8 nexthdr_type;
+ return (struct rmnet_map_v5_csum_header *)(skb->data +
+ sizeof(struct rmnet_map_header));
+}
+
+static u8 rmnet_map_get_next_hdr_type(struct sk_buff *skb)
+{
+ struct rmnet_map_v5_csum_header *hdr = rmnet_map_get_next_hdr(skb);
+
+ return u8_get_bits(hdr->header_info, MAPV5_HDRINFO_HDR_TYPE_FMASK);
+}
+
+static bool rmnet_map_get_csum_valid(struct sk_buff *skb)
+{
+ struct rmnet_map_v5_csum_header *hdr = rmnet_map_get_next_hdr(skb);
- next_hdr = (struct rmnet_map_v5_csum_header *)(skb->data +
- sizeof(struct rmnet_map_header));
+ return !!(hdr->csum_info & MAPV5_CSUMINFO_VALID_FLAG);
+}
+
+/* Stamp GSO metadata so the network stack can segment a coalesced SKB. */
+static void rmnet_map_gso_stamp(struct sk_buff *skb,
+ struct rmnet_map_coal_metadata *coal_meta)
+{
+ struct skb_shared_info *shinfo = skb_shinfo(skb);
- nexthdr_type = u8_get_bits(next_hdr->header_info,
- MAPV5_HDRINFO_HDR_TYPE_FMASK);
+ if (coal_meta->trans_proto == IPPROTO_TCP)
+ shinfo->gso_type = (coal_meta->ip_proto == 4) ?
+ SKB_GSO_TCPV4 : SKB_GSO_TCPV6;
+ else
+ shinfo->gso_type = SKB_GSO_UDP_L4;
- if (nexthdr_type != RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD)
+ shinfo->gso_size = coal_meta->data_len;
+ shinfo->gso_segs = coal_meta->pkt_count;
+}
+
+/* Set the transport checksum to the pseudo-header checksum and request
+ * partial checksum offload, letting the NIC or stack finish it.
+ */
+static void rmnet_map_partial_csum(struct sk_buff *skb,
+ struct rmnet_map_coal_metadata *coal_meta)
+{
+ u16 pkt_len = skb->len - coal_meta->ip_len;
+ unsigned char *data = skb->data;
+ __sum16 pseudo;
+
+ if (coal_meta->ip_proto == 4) {
+ struct iphdr *iph = (struct iphdr *)data;
+
+ pseudo = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
+ pkt_len, coal_meta->trans_proto, 0);
+ } else {
+ struct ipv6hdr *ip6h = (struct ipv6hdr *)data;
+
+ pseudo = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
+ pkt_len, coal_meta->trans_proto, 0);
+ }
+
+ if (coal_meta->trans_proto == IPPROTO_TCP) {
+ struct tcphdr *tp = (struct tcphdr *)(data + coal_meta->ip_len);
+
+ tp->check = pseudo;
+ skb->csum_offset = offsetof(struct tcphdr, check);
+ } else {
+ struct udphdr *up = (struct udphdr *)(data + coal_meta->ip_len);
+
+ up->check = pseudo;
+ skb->csum_offset = offsetof(struct udphdr, check);
+ }
+
+ skb->ip_summed = CHECKSUM_PARTIAL;
+ skb->csum_start = skb->data + coal_meta->ip_len - skb->head;
+}
+
+/* On some hardware, num_nlos in the coalescing header can be reported
+ * incorrectly under certain conditions even though the per-NLO num_packets
+ * fields it is meant to summarize are correct. Recompute the NLO count from
+ * the contiguous nl_pairs[] prefix rather than trusting the declared value.
+ * The first empty NLO marks the end of the prefix. Entries after it are not
+ * processed.
+ */
+static int rmnet_map_v5_get_num_nlos(const struct rmnet_map_v5_coal_header *coal_hdr)
+{
+ int nlos;
+
+ for (nlos = 0; nlos < RMNET_MAP_V5_MAX_NLOS; nlos++)
+ if (!coal_hdr->nl_pairs[nlos].num_packets)
+ break;
+
+ if (!nlos)
return -EINVAL;
- if (unlikely(!(skb->dev->features & NETIF_F_RXCSUM))) {
- priv->stats.csum_sw++;
- } else if (next_hdr->csum_info & MAPV5_CSUMINFO_VALID_FLAG) {
- priv->stats.csum_ok++;
- skb->ip_summed = CHECKSUM_UNNECESSARY;
+ return nlos;
+}
+
+static void rmnet_map_v5_set_nlos(struct rmnet_map_v5_coal_header *coal_hdr,
+ u8 nlos)
+{
+ coal_hdr->coal_info = u8_encode_bits(nlos, MAPV5_COALINFO_NUM_NLOS_FMASK) |
+ (coal_hdr->coal_info & MAPV5_COALINFO_CSUM_VALID_FLAG);
+}
+
+/* The frame-level CSUM_VALID indication for a single NLO, single packet
+ * coalescing frame cannot be trusted when the close reason is a TCP FIN/PSH,
+ * a packet count limit, a byte count limit or a time limit.
+ */
+static bool rmnet_map_v5_csum_fixup(struct rmnet_map_v5_coal_header *coal_hdr)
+{
+ u8 close_value = u8_get_bits(coal_hdr->close_info,
+ MAPV5_CLOSEINFO_CLOSE_VALUE_FMASK);
+ u8 close_type = u8_get_bits(coal_hdr->close_info,
+ MAPV5_CLOSEINFO_CLOSE_TYPE_FMASK);
+ u8 num_nlos = u8_get_bits(coal_hdr->coal_info,
+ MAPV5_COALINFO_NUM_NLOS_FMASK);
+
+ /* Only applies to single NLO, single packet frames */
+ if (num_nlos != 1 || coal_hdr->nl_pairs[0].num_packets != 1)
+ return false;
+
+ /* TCP FIN or PSH triggered the close */
+ if (close_type == RMNET_MAP_COAL_CLOSE_COAL)
+ return true;
+
+ /* Hit a hardware limit */
+ if (close_type == RMNET_MAP_COAL_CLOSE_HW) {
+ switch (close_value) {
+ case RMNET_MAP_COAL_CLOSE_HW_PKT:
+ case RMNET_MAP_COAL_CLOSE_HW_BYTE:
+ case RMNET_MAP_COAL_CLOSE_HW_TIME:
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/* Carve one logical segment from a coalesced SKB and append it to the list.
+ * Adjusts TCP sequence numbers, IP IDs/lengths, and checksum state.
+ */
+static void
+__rmnet_map_segment_coal_skb(struct sk_buff *coal_skb,
+ struct rmnet_map_coal_metadata *coal_meta,
+ struct sk_buff_head *list, u8 pkt_id,
+ bool csum_valid)
+{
+ u32 dlen = coal_meta->data_len * coal_meta->pkt_count;
+ struct rmnet_priv *priv = netdev_priv(coal_skb->dev);
+ u32 hlen = coal_meta->ip_len + coal_meta->trans_len;
+ struct rmnet_pcpu_stats *pcpu_ptr;
+ struct sk_buff *skbn;
+
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
+
+ /* RFC 768: UDP checksum is optional for IPv4, and is 0 if unused.
+ * Such packets are never actually bad, regardless of what the
+ * checksum bitmap says.
+ */
+ if (!csum_valid && coal_meta->zero_csum)
+ csum_valid = true;
+
+ if (!csum_valid) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ /* rx_dropped is standard accounting. coal_csum_drop is its
+ * coalescing-specific checksum error subset.
+ */
+ u64_stats_add(&pcpu_ptr->priv_stats.rx_dropped, coal_meta->pkt_count);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_csum_drop);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ goto next_pkt;
+ }
+
+ skbn = alloc_skb(hlen + dlen + RMNET_MAP_DEAGGR_HEADROOM, GFP_ATOMIC);
+ if (!skbn) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ /* The coal counter is the coalescing subset of the standard
+ * allocation failure and RX drop counters.
+ */
+ u64_stats_add(&pcpu_ptr->priv_stats.rx_alloc_fail, coal_meta->pkt_count);
+ u64_stats_add(&pcpu_ptr->priv_stats.rx_dropped, coal_meta->pkt_count);
+ u64_stats_add(&pcpu_ptr->priv_stats.coal_alloc_fail, coal_meta->pkt_count);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ goto next_pkt;
+ }
+
+ skb_reserve(skbn, hlen + RMNET_MAP_DEAGGR_HEADROOM);
+ skb_put_data(skbn,
+ coal_skb->data + coal_meta->ip_len + coal_meta->trans_len +
+ coal_meta->data_offset,
+ dlen);
+
+ /* Restore transport header */
+ skb_push(skbn, coal_meta->trans_len);
+ memcpy(skbn->data, coal_meta->trans_header, coal_meta->trans_len);
+ skb_reset_transport_header(skbn);
+
+ if (coal_meta->trans_proto == IPPROTO_TCP) {
+ struct tcphdr *th = tcp_hdr(skbn);
+
+ th->seq = htonl(ntohl(th->seq) + coal_meta->data_offset);
+ /* Strip dangerous flags from non-final segments */
+ if ((th->fin || th->psh) &&
+ hlen + coal_meta->data_offset + dlen < coal_skb->len) {
+ th->fin = 0;
+ th->psh = 0;
+ }
+ } else if (coal_meta->trans_proto == IPPROTO_UDP) {
+ struct udphdr *uh = udp_hdr(skbn);
+
+ uh->len = htons(skbn->len);
+ }
+
+ /* Restore IP header */
+ skb_push(skbn, coal_meta->ip_len);
+ memcpy(skbn->data, coal_meta->ip_header, coal_meta->ip_len);
+ skb_reset_network_header(skbn);
+
+ if (coal_meta->ip_proto == 4) {
+ struct iphdr *iph = ip_hdr(skbn);
+
+ iph->id = htons(ntohs(iph->id) + pkt_id);
+ iph->tot_len = htons(skbn->len);
+ iph->check = 0;
+ iph->check = ip_fast_csum(iph, iph->ihl);
+ } else {
+ ipv6_hdr(skbn)->payload_len =
+ htons(skbn->len - sizeof(struct ipv6hdr));
+ }
+
+ rmnet_map_partial_csum(skbn, coal_meta);
+
+ skbn->dev = coal_skb->dev;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_reconstruct);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+
+ if (coal_meta->pkt_count > 1)
+ rmnet_map_gso_stamp(skbn, coal_meta);
+
+ __skb_queue_tail(list, skbn);
+
+next_pkt:
+ coal_meta->data_offset += dlen;
+ coal_meta->pkt_count = 0;
+}
+
+/* Parse the IP header of the coalesced frame and perform basic
+ * validation of header fields.
+ */
+static bool rmnet_map_coal_parse_ip_hdr(struct sk_buff *coal_skb,
+ struct rmnet_map_coal_metadata *meta,
+ bool *gro)
+{
+ struct rmnet_priv *priv = netdev_priv(coal_skb->dev);
+ struct rmnet_pcpu_stats *pcpu_ptr;
+ struct ipv6hdr *ip6h;
+ struct iphdr *iph;
+ __be16 frag_off;
+ u8 protocol;
+ int ret;
+
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
+
+ if (coal_skb->len < sizeof(*iph)) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_ip_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ iph = (struct iphdr *)coal_skb->data;
+
+ if (iph->version == 4) {
+ meta->ip_proto = 4;
+ meta->ip_len = iph->ihl * 4;
+ meta->trans_proto = iph->protocol;
+ meta->ip_header = iph;
+ if (meta->ip_len < sizeof(*iph) || coal_skb->len < meta->ip_len) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_ip_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ if (ip_is_fragment(iph)) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_ip_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ if (iph->ihl != 5)
+ *gro = false;
+ } else if (iph->version == 6) {
+ if (coal_skb->len < sizeof(*ip6h)) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_ip_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ ip6h = (struct ipv6hdr *)iph;
+ protocol = ip6h->nexthdr;
+ meta->ip_proto = 6;
+ ret = ipv6_skip_exthdr(coal_skb, sizeof(*ip6h), &protocol,
+ &frag_off);
+ if (ret < 0 || frag_off || ret > U16_MAX) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_ip_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ meta->ip_len = (u16)ret;
+ meta->trans_proto = protocol;
+ meta->ip_header = ip6h;
+ if (coal_skb->len < meta->ip_len) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_ip_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ if (meta->ip_len > sizeof(*ip6h))
+ *gro = false;
+ } else {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_ip_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ return true;
+}
+
+/* Parse the transport header following the IP header into coal_meta. The
+ * available length is checked before any field is read.
+ */
+static bool rmnet_map_coal_parse_trans_hdr(struct sk_buff *coal_skb,
+ struct rmnet_map_coal_metadata *meta)
+{
+ struct rmnet_priv *priv = netdev_priv(coal_skb->dev);
+ struct rmnet_pcpu_stats *pcpu_ptr;
+ struct udphdr *uh;
+ struct tcphdr *th;
+ u32 avail;
+ u8 *base;
+
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
+
+ if (meta->ip_len > coal_skb->len) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_trans_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ base = (u8 *)meta->ip_header + meta->ip_len;
+ avail = coal_skb->len - meta->ip_len;
+
+ if (meta->trans_proto == IPPROTO_TCP) {
+ if (avail < sizeof(*th)) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_trans_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ th = (struct tcphdr *)base;
+ meta->trans_len = th->doff * 4;
+ meta->trans_header = th;
+ if (meta->trans_len < sizeof(*th) || avail < meta->trans_len) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_trans_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+ } else if (meta->trans_proto == IPPROTO_UDP) {
+ if (avail < sizeof(*uh)) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_trans_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ uh = (struct udphdr *)base;
+ meta->trans_len = sizeof(*uh);
+ meta->trans_header = uh;
+ if (meta->ip_proto == 4 && !uh->check)
+ meta->zero_csum = true;
} else {
- priv->stats.csum_valid_unset++;
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_trans_invalid);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return false;
+ }
+
+ return true;
+}
+
+/* Reject the frame unless the total data bytes claimed by all NLOs
+ * exactly match the actual payload in the SKB. Each pkt_len covers
+ * IP+transport headers plus per-packet data. Headers appear once, so
+ * subtract hlen per packet and track the running sum against available
+ * data. An exact match is required, not just an upper bound, so that
+ * GSO metadata stamped from the NLOs stays consistent with the real
+ * SKB length.
+ */
+static bool rmnet_map_coal_validate_bounds(struct sk_buff *coal_skb,
+ struct rmnet_map_v5_coal_header *coal_hdr,
+ u8 num_nlos, u32 hlen, bool *gro)
+{
+ u32 total_data = 0;
+ u32 nlo_len;
+ u16 plen;
+ u8 i;
+
+ if (hlen > coal_skb->len)
+ return false;
+
+ for (i = 0; i < num_nlos; i++) {
+ plen = ntohs(coal_hdr->nl_pairs[i].pkt_len);
+
+ if (plen < hlen)
+ return false;
+
+ /* Zero-payload packets cannot use GSO with a zero gso_size. */
+ if (plen == hlen)
+ *gro = false;
+
+ nlo_len = (u32)(plen - hlen) * coal_hdr->nl_pairs[i].num_packets;
+ if (nlo_len > coal_skb->len - hlen - total_data)
+ return false;
+
+ total_data += nlo_len;
+ }
+
+ return total_data == coal_skb->len - hlen;
+}
+
+/* Attempt the GRO-friendly fast path for a single-NLO, checksum-valid frame
+ * by reusing the original SKB and stamping GSO metadata instead of copying
+ * out each segment. Returns true if the frame was consumed via the fast
+ * path, or false if the caller should fall back to full segmentation.
+ */
+static bool rmnet_map_coal_gro_fast_path(struct sk_buff *coal_skb,
+ struct rmnet_map_v5_coal_header *coal_hdr,
+ struct rmnet_map_coal_metadata *coal_meta,
+ struct sk_buff_head *list,
+ u8 num_nlos, bool gro)
+{
+ u32 hlen = coal_meta->ip_len + coal_meta->trans_len;
+
+ if (!gro || num_nlos != 1 ||
+ !(coal_hdr->coal_info & MAPV5_COALINFO_CSUM_VALID_FLAG))
+ return false;
+
+ coal_meta->data_len = ntohs(coal_hdr->nl_pairs[0].pkt_len) - hlen;
+ coal_meta->pkt_count = coal_hdr->nl_pairs[0].num_packets;
+
+ coal_skb->ip_summed = CHECKSUM_UNNECESSARY;
+ if (coal_meta->pkt_count > 1) {
+ rmnet_map_partial_csum(coal_skb, coal_meta);
+ rmnet_map_gso_stamp(coal_skb, coal_meta);
+ }
+
+ __skb_queue_tail(list, coal_skb);
+ return true;
+}
+
+/* NLO packet lengths are already bounds-checked by
+ * rmnet_map_coal_validate_bounds() so no further validation is needed here.
+ */
+static void rmnet_map_coal_segment_loop(struct sk_buff *coal_skb,
+ struct rmnet_map_v5_coal_header *coal_hdr,
+ struct rmnet_map_coal_metadata *coal_meta,
+ struct sk_buff_head *list,
+ u64 nlo_err_mask, bool gro, u8 num_nlos)
+{
+ struct rmnet_priv *priv = netdev_priv(coal_skb->dev);
+ u32 hlen = coal_meta->ip_len + coal_meta->trans_len;
+ struct rmnet_pcpu_stats *pcpu_ptr;
+ u8 pkt, total_pkt = 0;
+ bool csum_err;
+ u16 pkt_len;
+ u8 nlo;
+
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
+
+ for (nlo = 0; nlo < num_nlos; nlo++) {
+ pkt_len = ntohs(coal_hdr->nl_pairs[nlo].pkt_len);
+ pkt_len -= hlen;
+ coal_meta->data_len = pkt_len;
+
+ /* nlo_err_mask is one flat bitstream across all NLOs. Shift
+ * it once per packet in absolute frame order and do not
+ * re-align at the NLO boundary above. See the comment on
+ * rmnet_map_data_check_coal_header() for why.
+ */
+ for (pkt = 0; pkt < coal_hdr->nl_pairs[nlo].num_packets;
+ pkt++, total_pkt++, nlo_err_mask >>= 1) {
+ csum_err = nlo_err_mask & 1;
+
+ if (csum_err) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_csum_err);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ }
+
+ if (!gro) {
+ coal_meta->pkt_count = 1;
+ __rmnet_map_segment_coal_skb(coal_skb, coal_meta,
+ list, total_pkt,
+ !csum_err);
+ continue;
+ }
+
+ if (csum_err) {
+ if (coal_meta->pkt_count)
+ __rmnet_map_segment_coal_skb(coal_skb,
+ coal_meta,
+ list,
+ total_pkt -
+ coal_meta->pkt_count,
+ true);
+ coal_meta->pkt_count = 1;
+ __rmnet_map_segment_coal_skb(coal_skb, coal_meta,
+ list, total_pkt,
+ false);
+ } else {
+ coal_meta->pkt_count++;
+ }
+ }
+
+ /* Flush remaining packets from this NLO */
+ if (coal_meta->pkt_count)
+ __rmnet_map_segment_coal_skb(coal_skb, coal_meta, list,
+ total_pkt - coal_meta->pkt_count, true);
+ }
+}
+
+/* Expand a coalesced SKB into individual IP packets placed on the list.
+ * NLOs with checksum errors are dropped. __rmnet_map_ingress_handler will
+ * free the SKB in the error case.
+ */
+static int rmnet_map_segment_coal_skb(struct sk_buff *coal_skb,
+ u64 nlo_err_mask,
+ struct sk_buff_head *list,
+ u16 len, u16 total_pkts, u8 num_nlos)
+{
+ bool gro_hw = coal_skb->dev->features & NETIF_F_GRO_HW;
+ bool rxcsum = coal_skb->dev->features & NETIF_F_RXCSUM;
+ struct rmnet_priv *priv = netdev_priv(coal_skb->dev);
+ struct rmnet_map_v5_coal_header *coal_hdr;
+ struct rmnet_map_coal_metadata coal_meta;
+ struct rmnet_pcpu_stats *pcpu_ptr;
+ bool gro = gro_hw;
+ u32 hlen;
+
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
+
+ memset(&coal_meta, 0, sizeof(coal_meta));
+
+ /* Drop any MAP frame padding. The coal header is counted in len */
+ skb_pull(coal_skb, sizeof(struct rmnet_map_header));
+ skb_trim(coal_skb, len);
+ coal_hdr = (struct rmnet_map_v5_coal_header *)coal_skb->data;
+ rmnet_map_v5_set_nlos(coal_hdr, num_nlos);
+ skb_pull(coal_skb, sizeof(*coal_hdr));
+
+ if (!rmnet_map_coal_parse_ip_hdr(coal_skb, &coal_meta, &gro))
+ return -EINVAL;
+
+ if (!rmnet_map_coal_parse_trans_hdr(coal_skb, &coal_meta))
+ return -EINVAL;
+
+ hlen = coal_meta.ip_len + coal_meta.trans_len;
+
+ if (!rmnet_map_coal_validate_bounds(coal_skb, coal_hdr, num_nlos, hlen,
+ &gro)) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_bounds_err);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return -EINVAL;
+ }
+
+ /* Device capability gates coalesced delivery. Packet format can still
+ * disable GSO and use the per-packet fallback below.
+ */
+ if (total_pkts > 1 && (!rxcsum || !gro_hw))
+ return -EINVAL;
+
+ if (gro && total_pkts > 1) {
+ /* Standard counters cover delivered HW-GRO skbs. coal_rx and
+ * coal_pkts cover coalescing input regardless of HW-GRO.
+ */
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.rx_hw_gro_packets);
+ u64_stats_add(&pcpu_ptr->priv_stats.rx_hw_gro_wire_packets, total_pkts);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ }
+
+ if (total_pkts == 1 && (!rxcsum || !gro_hw)) {
+ coal_skb->ip_summed = CHECKSUM_NONE;
+ __skb_queue_tail(list, coal_skb);
+ return 0;
+ }
+
+ if (rmnet_map_v5_csum_fixup(coal_hdr) && !coal_meta.zero_csum) {
+ coal_skb->ip_summed = CHECKSUM_NONE;
+ __skb_queue_tail(list, coal_skb);
+ return 0;
+ }
+
+ if (rmnet_map_coal_gro_fast_path(coal_skb, coal_hdr, &coal_meta, list,
+ num_nlos, gro))
+ return 0;
+
+ rmnet_map_coal_segment_loop(coal_skb, coal_hdr, &coal_meta, list,
+ nlo_err_mask, gro, num_nlos);
+
+ return 0;
+}
+
+/* Log the hardware close-reason counter for a coalescing header. */
+static void rmnet_map_data_log_close_stats(struct rmnet_pcpu_stats *pcpu_ptr,
+ u8 type, u8 code)
+{
+ switch (type) {
+ case RMNET_MAP_COAL_CLOSE_NON_COAL:
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_close_non_coal);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ break;
+ case RMNET_MAP_COAL_CLOSE_IP_MISS:
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_close_ip_miss);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ break;
+ case RMNET_MAP_COAL_CLOSE_TRANS_MISS:
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_close_trans_miss);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ break;
+ case RMNET_MAP_COAL_CLOSE_HW:
+ switch (code) {
+ case RMNET_MAP_COAL_CLOSE_HW_NL:
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_close_hw_nl);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ break;
+ case RMNET_MAP_COAL_CLOSE_HW_PKT:
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_close_hw_pkt);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ break;
+ case RMNET_MAP_COAL_CLOSE_HW_BYTE:
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_close_hw_byte);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ break;
+ case RMNET_MAP_COAL_CLOSE_HW_TIME:
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_close_hw_time);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ break;
+ case RMNET_MAP_COAL_CLOSE_HW_EVICT:
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_close_hw_evict);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ break;
+ default:
+ break;
+ }
+ break;
+ case RMNET_MAP_COAL_CLOSE_COAL:
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_close_coal);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ break;
+ default:
+ break;
}
+}
- /* Pull csum v5 header */
- skb_pull(skb, sizeof(*next_hdr));
+/* Validate the coalescing header and build the checksum error mask.
+ *
+ * Checks performed:
+ * - MAP pkt_len accommodates the coal header (coal header is counted in
+ * pkt_len. pkt_len < sizeof(*coal_hdr) means no payload is possible).
+ * - num_nlos is in [1, RMNET_MAP_V5_MAX_NLOS].
+ * - Total packet count does not exceed RMNET_MAP_V5_MAX_PACKETS.
+ *
+ * nlo_err_mask is NOT six independent per-NLO bitmaps. Each nl_pairs
+ * slot only has room for an 8 bit csum_error_bitmap, but a single NLO
+ * can carry more than 8 packets (up to RMNET_MAP_V5_MAX_PACKETS), so
+ * hardware spills a wide NLO's error bits into the csum_error_bitmap
+ * bytes of the following slots rather than truncating them. The
+ * six bitmap bytes are therefore always concatenated in slot order
+ * into one flat RMNET_MAP_V5_MAX_NLOS * 8 = RMNET_MAP_V5_MAX_PACKETS
+ * bit value, addressed by a packet's absolute position in the frame,
+ * regardless of how many NLOs are actually in use. Receivers must
+ * walk it as a single contiguous stream and must not expect it to
+ * align it at NLO boundaries.
+ */
+static int rmnet_map_data_check_coal_header(struct sk_buff *skb,
+ u64 *nlo_err_mask,
+ u8 *num_nlos,
+ u16 *num_pkts)
+{
+ struct rmnet_map_header *maph = (struct rmnet_map_header *)skb->data;
+ struct rmnet_priv *priv = netdev_priv(skb->dev);
+ struct rmnet_map_v5_coal_header *coal_hdr;
+ struct rmnet_pcpu_stats *pcpu_ptr;
+ u16 pkts = 0;
+ u64 mask = 0;
+ int nlos;
+ int i;
+
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
+
+ /* coal header is counted in pkt_len */
+ if (ntohs(maph->pkt_len) < sizeof(*coal_hdr)) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_hdr_err);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return -EINVAL;
+ }
+
+ coal_hdr = (struct rmnet_map_v5_coal_header *)(skb->data + sizeof(*maph));
+ nlos = rmnet_map_v5_get_num_nlos(coal_hdr);
+ if (nlos < 0) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_hdr_err);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return -EINVAL;
+ }
+
+ *num_nlos = nlos;
+ for (i = 0; i < RMNET_MAP_V5_MAX_NLOS; i++) {
+ u8 err = coal_hdr->nl_pairs[i].csum_error_bitmap;
+ u8 pkt = coal_hdr->nl_pairs[i].num_packets;
+
+ mask |= ((u64)err) << (8 * i);
+ if (i < *num_nlos) {
+ pkts += pkt;
+ if (pkts > RMNET_MAP_V5_MAX_PACKETS) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_hdr_pkt_err);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ return -EINVAL;
+ }
+ }
+ }
+
+ /* coal_pkts counts packets reported by the hardware, independent of
+ * whether the frame is later delivered through HW-GRO.
+ */
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_add(&pcpu_ptr->priv_stats.coal_pkts, pkts);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ rmnet_map_data_log_close_stats(pcpu_ptr,
+ u8_get_bits(coal_hdr->close_info,
+ MAPV5_CLOSEINFO_CLOSE_TYPE_FMASK),
+ u8_get_bits(coal_hdr->close_info,
+ MAPV5_CLOSEINFO_CLOSE_VALUE_FMASK));
+
+ *nlo_err_mask = mask;
+ *num_pkts = pkts;
+ return 0;
+}
+
+int rmnet_map_process_next_hdr_packet(struct sk_buff *skb,
+ struct sk_buff_head *list,
+ u16 len, u32 data_format)
+{
+ struct rmnet_priv *priv = netdev_priv(skb->dev);
+ struct rmnet_pcpu_stats *pcpu_ptr;
+ u64 nlo_err_mask;
+ u16 num_pkts;
+ u8 num_nlos;
+ int rc;
+
+ pcpu_ptr = this_cpu_ptr(priv->pcpu_stats);
+
+ switch (rmnet_map_get_next_hdr_type(skb)) {
+ case RMNET_MAP_HEADER_TYPE_COALESCING:
+ if (!(data_format & RMNET_FLAGS_INGRESS_COALESCE))
+ return -EINVAL;
+
+ /* coal_rx counts coalescing input, not delivered HW-GRO skbs. */
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.coal_rx);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ rc = rmnet_map_data_check_coal_header(skb, &nlo_err_mask,
+ &num_nlos, &num_pkts);
+ if (rc)
+ return rc;
+
+ /* Coalescing rewrites shared packet data and GSO metadata. */
+ if (skb_unclone(skb, GFP_ATOMIC))
+ return -ENOMEM;
+
+ rc = rmnet_map_segment_coal_skb(skb, nlo_err_mask, list, len,
+ num_pkts, num_nlos);
+ if (rc)
+ return rc;
+
+ if (skb_peek(list) != skb) {
+ if (skb_queue_empty(list))
+ kfree_skb(skb);
+ else
+ consume_skb(skb);
+ }
+ break;
+
+ case RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD:
+ if (unlikely(!(skb->dev->features & NETIF_F_RXCSUM))) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_sw);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ } else if (rmnet_map_get_csum_valid(skb)) {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_ok);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+ } else {
+ u64_stats_update_begin(&pcpu_ptr->syncp);
+ u64_stats_inc(&pcpu_ptr->priv_stats.csum_valid_unset);
+ u64_stats_update_end(&pcpu_ptr->syncp);
+ }
+
+ skb_pull(skb, sizeof(struct rmnet_map_header) +
+ sizeof(struct rmnet_map_v5_csum_header));
+ skb_trim(skb, len);
+ __skb_queue_tail(list, skb);
+ break;
+
+ default:
+ return -EINVAL;
+ }
return 0;
}
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
index 5f921cddf82b4..8e2a83ca02355 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
@@ -7,6 +7,7 @@
#include <linux/capability.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
+#include <net/netdev_queues.h>
#include <linux/if_arp.h>
#include <linux/netlink.h>
#include <net/pkt_sched.h>
@@ -66,27 +67,25 @@ static netdev_tx_t rmnet_vnd_start_xmit(struct sk_buff *skb,
return NETDEV_TX_OK;
}
-static int rmnet_vnd_headroom(struct rmnet_port *port)
+static int rmnet_vnd_headroom(u32 data_format)
{
u32 headroom;
headroom = sizeof(struct rmnet_map_header);
- if (port->data_format & RMNET_FLAGS_EGRESS_MAP_CKSUMV4)
+ if (data_format & RMNET_FLAGS_EGRESS_MAP_CKSUMV4)
headroom += sizeof(struct rmnet_map_ul_csum_header);
return headroom;
}
-static int rmnet_vnd_change_mtu(struct net_device *rmnet_dev, int new_mtu)
+static int rmnet_vnd_change_mtu_with_format(struct net_device *rmnet_dev,
+ int new_mtu, u32 data_format)
{
struct rmnet_priv *priv = netdev_priv(rmnet_dev);
- struct rmnet_port *port;
u32 headroom;
- port = rmnet_get_port_rtnl(priv->real_dev);
-
- headroom = rmnet_vnd_headroom(port);
+ headroom = rmnet_vnd_headroom(data_format);
if (new_mtu < 0 || new_mtu > RMNET_MAX_PACKET_SIZE ||
new_mtu > (priv->real_dev->mtu - headroom))
@@ -96,6 +95,17 @@ static int rmnet_vnd_change_mtu(struct net_device *rmnet_dev, int new_mtu)
return 0;
}
+static int rmnet_vnd_change_mtu(struct net_device *rmnet_dev, int new_mtu)
+{
+ struct rmnet_priv *priv = netdev_priv(rmnet_dev);
+ struct rmnet_port *port;
+
+ port = rmnet_get_port_rtnl(priv->real_dev);
+
+ return rmnet_vnd_change_mtu_with_format(rmnet_dev, new_mtu,
+ READ_ONCE(port->data_format));
+}
+
static int rmnet_vnd_get_iflink(const struct net_device *dev)
{
struct rmnet_priv *priv = netdev_priv(dev);
@@ -132,7 +142,9 @@ static void rmnet_vnd_uninit(struct net_device *dev)
static void rmnet_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *s)
{
+ struct rmnet_priv_stats total_priv_stats = { };
struct rmnet_priv *priv = netdev_priv(dev);
+ struct rmnet_priv_stats priv_snapshot;
struct rmnet_vnd_stats total_stats = { };
struct rmnet_pcpu_stats *pcpu_ptr;
struct rmnet_vnd_stats snapshot;
@@ -144,6 +156,8 @@ static void rmnet_get_stats64(struct net_device *dev,
do {
start = u64_stats_fetch_begin(&pcpu_ptr->syncp);
snapshot = pcpu_ptr->stats; /* struct assignment */
+ u64_stats_copy(&priv_snapshot, &pcpu_ptr->priv_stats,
+ sizeof(priv_snapshot));
} while (u64_stats_fetch_retry(&pcpu_ptr->syncp, start));
total_stats.rx_pkts += snapshot.rx_pkts;
@@ -151,6 +165,7 @@ static void rmnet_get_stats64(struct net_device *dev,
total_stats.tx_pkts += snapshot.tx_pkts;
total_stats.tx_bytes += snapshot.tx_bytes;
total_stats.tx_drops += snapshot.tx_drops;
+ total_priv_stats.rx_dropped += priv_snapshot.rx_dropped;
}
s->rx_packets = total_stats.rx_pkts;
@@ -158,8 +173,45 @@ static void rmnet_get_stats64(struct net_device *dev,
s->tx_packets = total_stats.tx_pkts;
s->tx_bytes = total_stats.tx_bytes;
s->tx_dropped = total_stats.tx_drops;
+ s->rx_dropped = total_priv_stats.rx_dropped;
}
+/* Report standard network stack RX statistics. These are distinct from the
+ * rmnet-specific coalescing diagnostics exposed through ethtool.
+ */
+static void rmnet_get_queue_stats_rx(struct net_device *dev, int idx,
+ struct netdev_queue_stats_rx *stats)
+{
+ struct rmnet_priv *priv = netdev_priv(dev);
+ struct rmnet_priv_stats total_stats = { };
+ struct rmnet_pcpu_stats *pcpu_ptr;
+ struct rmnet_priv_stats snapshot;
+ unsigned int cpu, start;
+
+ for_each_possible_cpu(cpu) {
+ pcpu_ptr = per_cpu_ptr(priv->pcpu_stats, cpu);
+
+ do {
+ start = u64_stats_fetch_begin(&pcpu_ptr->syncp);
+ u64_stats_copy(&snapshot, &pcpu_ptr->priv_stats,
+ sizeof(snapshot));
+ } while (u64_stats_fetch_retry(&pcpu_ptr->syncp, start));
+
+ total_stats.rx_hw_gro_packets += snapshot.rx_hw_gro_packets;
+ total_stats.rx_hw_gro_wire_packets +=
+ snapshot.rx_hw_gro_wire_packets;
+ total_stats.rx_alloc_fail += snapshot.rx_alloc_fail;
+ }
+
+ stats->hw_gro_packets = total_stats.rx_hw_gro_packets;
+ stats->hw_gro_wire_packets = total_stats.rx_hw_gro_wire_packets;
+ stats->alloc_fail = total_stats.rx_alloc_fail;
+}
+
+static const struct netdev_stat_ops rmnet_stat_ops = {
+ .get_queue_stats_rx = rmnet_get_queue_stats_rx,
+};
+
static const struct net_device_ops rmnet_vnd_ops = {
.ndo_start_xmit = rmnet_vnd_start_xmit,
.ndo_change_mtu = rmnet_vnd_change_mtu,
@@ -183,8 +235,34 @@ static const char rmnet_gstrings_stats[][ETH_GSTRING_LEN] = {
"Checksum skipped",
"Checksum computed in software",
"Checksum computed in hardware",
+ /* DL coalescing */
+ "Coal alloc packet drops",
+ "Coal frames received",
+ "Packets in coal frames",
+ "Coal header errors",
+ "Coal hdr pkt count errors",
+ "Coal bounds errors",
+ "Coal checksum errors",
+ "Coal packets dropped on csum err",
+ "Coal segments reconstructed",
+ "Coal invalid IP packet",
+ "Coal invalid transport",
+ /* close reasons */
+ "Coal closed: non-coal",
+ "Coal closed: IP miss",
+ "Coal closed: transport miss",
+ "Coal closed: hw NL limit",
+ "Coal closed: hw pkt limit",
+ "Coal closed: hw byte limit",
+ "Coal closed: hw time limit",
+ "Coal closed: hw evict",
+ "Coal closed: FIN/PSH",
};
+static_assert(ARRAY_SIZE(rmnet_gstrings_stats) ==
+ (sizeof(struct rmnet_priv_stats) -
+ offsetof(struct rmnet_priv_stats, csum_ok)) / sizeof(u64));
+
static void rmnet_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
{
switch (stringset) {
@@ -209,12 +287,62 @@ static void rmnet_get_ethtool_stats(struct net_device *dev,
struct ethtool_stats *stats, u64 *data)
{
struct rmnet_priv *priv = netdev_priv(dev);
- struct rmnet_priv_stats *st = &priv->stats;
+ struct rmnet_priv_stats total_stats = { };
+ struct rmnet_pcpu_stats *pcpu_ptr;
+ struct rmnet_priv_stats snapshot;
+ unsigned int cpu, start;
if (!data)
return;
- memcpy(data, st, ARRAY_SIZE(rmnet_gstrings_stats) * sizeof(u64));
+ for_each_possible_cpu(cpu) {
+ pcpu_ptr = per_cpu_ptr(priv->pcpu_stats, cpu);
+
+ do {
+ start = u64_stats_fetch_begin(&pcpu_ptr->syncp);
+ u64_stats_copy(&snapshot, &pcpu_ptr->priv_stats,
+ sizeof(snapshot));
+ } while (u64_stats_fetch_retry(&pcpu_ptr->syncp, start));
+
+ total_stats.csum_ok += snapshot.csum_ok;
+ total_stats.csum_ip4_header_bad += snapshot.csum_ip4_header_bad;
+ total_stats.csum_valid_unset += snapshot.csum_valid_unset;
+ total_stats.csum_validation_failed += snapshot.csum_validation_failed;
+ total_stats.csum_err_bad_buffer += snapshot.csum_err_bad_buffer;
+ total_stats.csum_err_invalid_ip_version +=
+ snapshot.csum_err_invalid_ip_version;
+ total_stats.csum_err_invalid_transport +=
+ snapshot.csum_err_invalid_transport;
+ total_stats.csum_fragmented_pkt += snapshot.csum_fragmented_pkt;
+ total_stats.csum_skipped += snapshot.csum_skipped;
+ total_stats.csum_sw += snapshot.csum_sw;
+ total_stats.csum_hw += snapshot.csum_hw;
+ /* Custom rmnet coalescing diagnostics follow. */
+ total_stats.coal_alloc_fail += snapshot.coal_alloc_fail;
+ total_stats.coal_rx += snapshot.coal_rx;
+ total_stats.coal_pkts += snapshot.coal_pkts;
+ total_stats.coal_hdr_err += snapshot.coal_hdr_err;
+ total_stats.coal_hdr_pkt_err += snapshot.coal_hdr_pkt_err;
+ total_stats.coal_bounds_err += snapshot.coal_bounds_err;
+ total_stats.coal_csum_err += snapshot.coal_csum_err;
+ total_stats.coal_csum_drop += snapshot.coal_csum_drop;
+ total_stats.coal_reconstruct += snapshot.coal_reconstruct;
+ total_stats.coal_ip_invalid += snapshot.coal_ip_invalid;
+ total_stats.coal_trans_invalid += snapshot.coal_trans_invalid;
+ total_stats.coal_close_non_coal += snapshot.coal_close_non_coal;
+ total_stats.coal_close_ip_miss += snapshot.coal_close_ip_miss;
+ total_stats.coal_close_trans_miss += snapshot.coal_close_trans_miss;
+ total_stats.coal_close_hw_nl += snapshot.coal_close_hw_nl;
+ total_stats.coal_close_hw_pkt += snapshot.coal_close_hw_pkt;
+ total_stats.coal_close_hw_byte += snapshot.coal_close_hw_byte;
+ total_stats.coal_close_hw_time += snapshot.coal_close_hw_time;
+ total_stats.coal_close_hw_evict += snapshot.coal_close_hw_evict;
+ total_stats.coal_close_coal += snapshot.coal_close_coal;
+ }
+
+ /* The first four fields are reported through netdev queue statistics. */
+ memcpy(data, &total_stats.csum_ok,
+ sizeof(total_stats) - offsetof(struct rmnet_priv_stats, csum_ok));
}
static int rmnet_get_coalesce(struct net_device *dev,
@@ -308,8 +436,7 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
struct rmnet_port *port,
struct net_device *real_dev,
struct rmnet_endpoint *ep,
- struct netlink_ext_ack *extack)
-
+ struct netlink_ext_ack *extack, u32 data_format)
{
struct rmnet_priv *priv = netdev_priv(rmnet_dev);
u32 headroom;
@@ -323,12 +450,16 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
rmnet_dev->hw_features = NETIF_F_RXCSUM;
rmnet_dev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
rmnet_dev->hw_features |= NETIF_F_SG;
+ rmnet_dev->hw_features |= NETIF_F_GRO_HW;
+ rmnet_dev->stat_ops = &rmnet_stat_ops;
priv->real_dev = real_dev;
- headroom = rmnet_vnd_headroom(port);
+ headroom = rmnet_vnd_headroom(data_format);
- if (rmnet_vnd_change_mtu(rmnet_dev, real_dev->mtu - headroom)) {
+ if (rmnet_vnd_change_mtu_with_format(rmnet_dev,
+ real_dev->mtu - headroom,
+ data_format)) {
NL_SET_ERR_MSG_MOD(extack, "Invalid MTU on real dev");
return -EINVAL;
}
@@ -375,17 +506,15 @@ int rmnet_vnd_do_flow_control(struct net_device *rmnet_dev, int enable)
return 0;
}
-int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev)
+static int rmnet_vnd_validate_mtu(struct rmnet_port *port,
+ struct net_device *real_dev, u32 data_format)
{
struct hlist_node *tmp_ep;
struct rmnet_endpoint *ep;
- struct rmnet_port *port;
unsigned long bkt_ep;
u32 headroom;
- port = rmnet_get_port_rtnl(real_dev);
-
- headroom = rmnet_vnd_headroom(port);
+ headroom = rmnet_vnd_headroom(data_format);
hash_for_each_safe(port->muxed_ep, bkt_ep, tmp_ep, ep, hlnode) {
if (ep->egress_dev->mtu > (real_dev->mtu - headroom))
@@ -395,23 +524,39 @@ int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev)
return 0;
}
+int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev)
+{
+ struct rmnet_port *port;
+
+ port = rmnet_get_port_rtnl(real_dev);
+
+ return rmnet_vnd_validate_mtu(port, real_dev,
+ READ_ONCE(port->data_format));
+}
+
int rmnet_vnd_update_dev_mtu(struct rmnet_port *port,
- struct net_device *real_dev)
+ struct net_device *real_dev, u32 data_format)
{
struct hlist_node *tmp_ep;
struct rmnet_endpoint *ep;
unsigned long bkt_ep;
u32 headroom;
+ int new_mtu;
- headroom = rmnet_vnd_headroom(port);
+ headroom = rmnet_vnd_headroom(data_format);
+ if (real_dev->mtu < headroom)
+ return -EINVAL;
+
+ new_mtu = real_dev->mtu - headroom;
+ if (new_mtu > RMNET_MAX_PACKET_SIZE)
+ return -EINVAL;
hash_for_each_safe(port->muxed_ep, bkt_ep, tmp_ep, ep, hlnode) {
- if (ep->egress_dev->mtu <= (real_dev->mtu - headroom))
+ if (ep->egress_dev->mtu <= new_mtu)
continue;
- if (rmnet_vnd_change_mtu(ep->egress_dev,
- real_dev->mtu - headroom))
- return -1;
+ /* The target MTU was validated before updating any endpoint. */
+ WRITE_ONCE(ep->egress_dev->mtu, new_mtu);
}
return 0;
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h
index c2b2baf86894e..901ef36900ac3 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h
@@ -12,7 +12,7 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
struct rmnet_port *port,
struct net_device *real_dev,
struct rmnet_endpoint *ep,
- struct netlink_ext_ack *extack);
+ struct netlink_ext_ack *extack, u32 data_format);
int rmnet_vnd_dellink(u8 id, struct rmnet_port *port,
struct rmnet_endpoint *ep);
void rmnet_vnd_rx_fixup(struct sk_buff *skb, struct net_device *dev);
@@ -21,5 +21,5 @@ void rmnet_vnd_tx_fixup(struct sk_buff *skb, struct net_device *dev);
void rmnet_vnd_setup(struct net_device *dev);
int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev);
int rmnet_vnd_update_dev_mtu(struct rmnet_port *port,
- struct net_device *real_dev);
+ struct net_device *real_dev, u32 data_format);
#endif /* _RMNET_VND_H_ */
diff --git a/include/linux/if_rmnet.h b/include/linux/if_rmnet.h
index c44bf6e80ecb4..5df4d417f3d2c 100644
--- a/include/linux/if_rmnet.h
+++ b/include/linux/if_rmnet.h
@@ -70,5 +70,36 @@ struct rmnet_map_v5_csum_header {
#define MAPV5_HDRINFO_HDR_TYPE_FMASK GENMASK(7, 1)
#define MAPV5_CSUMINFO_VALID_FLAG BIT(7)
+#define RMNET_MAP_HEADER_TYPE_COALESCING 1
#define RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD 2
+
+/* MAPv5 coalescing header */
+#define RMNET_MAP_V5_MAX_NLOS 6
+#define RMNET_MAP_V5_MAX_PACKETS 48
+
+/* One Number-Length Object pair: per-NLO packet count and length. */
+struct rmnet_map_v5_nl_pair {
+ __be16 pkt_len;
+ u8 csum_error_bitmap;
+ u8 num_packets;
+} __aligned(1);
+
+/* MAPv5 coalescing header: describes up to RMNET_MAP_V5_MAX_NLOS NLOs.
+ * The header immediately follows the MAP header in the frame and is
+ * included in the MAP pkt_len field.
+ */
+struct rmnet_map_v5_coal_header {
+ u8 header_info; /* MAPV5_HDRINFO_NXT_HDR_FLAG, MAPV5_HDRINFO_HDR_TYPE_FMASK */
+ u8 coal_info; /* MAPV5_COALINFO_* */
+ u8 close_info; /* MAPV5_CLOSEINFO_* */
+ u8 veid_info; /* MAPV5_VEIDINFO_* */
+ struct rmnet_map_v5_nl_pair nl_pairs[RMNET_MAP_V5_MAX_NLOS];
+} __aligned(1);
+
+#define MAPV5_COALINFO_NUM_NLOS_FMASK GENMASK(6, 4)
+#define MAPV5_COALINFO_CSUM_VALID_FLAG BIT(7)
+#define MAPV5_CLOSEINFO_CLOSE_TYPE_FMASK GENMASK(3, 0)
+#define MAPV5_CLOSEINFO_CLOSE_VALUE_FMASK GENMASK(7, 4)
+#define MAPV5_VEIDINFO_VEID_FMASK GENMASK(3, 0)
+
#endif /* !(_LINUX_IF_RMNET_H_) */
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index 245b362045253..349fcddc6622f 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -2022,6 +2022,7 @@ enum {
#define RMNET_FLAGS_EGRESS_MAP_CKSUMV4 (1U << 3)
#define RMNET_FLAGS_INGRESS_MAP_CKSUMV5 (1U << 4)
#define RMNET_FLAGS_EGRESS_MAP_CKSUMV5 (1U << 5)
+#define RMNET_FLAGS_INGRESS_COALESCE (1U << 6)
enum {
IFLA_RMNET_UNSPEC,
|
| 39/3 | 2026/10/08 01:22 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 32058 output: 38 thoughts: 1498 Thoughts: **KMSAN Evaluation: RMNET Patch Series**
Okay, let's break this down. The request is to determine if this patch series warrants a dedicated KMSAN fuzzing session. My expert eye is immediately drawn to the areas where uninitialized memory might be a problem, or where data is being passed to userspace.
First, I see documentation updates and some configuration changes within `rmnet_config.c` and `rmnet_config.h`. Nothing immediately screaming KMSAN here, just checks and updates to MTU and configuration flags, and the addition of per-CPU stats. We are using `pcpu_stats` instead of `priv->stats`.
Next, the `rmnet_handlers.c` changes introduce `rmnet_deliver_skb_list` and updates to `__rmnet_map_ingress_handler` for coalesced frames. While handling lists of SKBs is always something to pay attention to, the core logic relies on `rmnet_map_process_next_hdr_packet`, which itself seems to be the focus of significant changes in the `rmnet_map_data.c` file. This means there is some new coalescing logic for DL packets. Within the `rmnet_map_data.c` file, I note `struct rmnet_map_coal_metadata`, and that the code appears to validate bounds and handles segmentation. This is a potential area to look at more closely for uninitialized reads and bounds issues.
Now, let's zoom in on `rmnet_vnd.c`. Here we have `rmnet_get_stats64`, `rmnet_get_queue_stats_rx` and `rmnet_get_ethtool_stats` which are important because these functions *copy* kernel data to user space. That's where I need to be careful.
Specifically, in `rmnet_get_stats64`, a critical section grabs the statistics via snapshots of per-CPU stats. I need to be absolutely certain that those per-CPU stats (`pcpu_stats`) are initialized correctly *before* we make this snapshot. I also see they are being accumulated to a total. I have to look more closely:
```c
struct rmnet_priv_stats total_priv_stats = { };
struct rmnet_priv *priv = netdev_priv(dev);
struct rmnet_priv_stats priv_snapshot;
struct rmnet_vnd_stats total_stats = { };
struct rmnet_pcpu_stats *pcpu_ptr;
struct rmnet_vnd_stats snapshot;
unsigned int cpu, start;
for_each_possible_cpu(cpu) {
pcpu_ptr = per_cpu_ptr(priv->pcpu_stats, cpu);
do {
start = u64_stats_fetch_begin(&pcpu_ptr->syncp);
snapshot = pcpu_ptr->stats; /* struct assignment */
u64_stats_copy(&priv_snapshot, &pcpu_ptr->priv_stats,
sizeof(priv_snapshot));
} while (u64_stats_fetch_retry(&pcpu_ptr->syncp, start));
total_stats.rx_pkts += snapshot.rx_pkts;
total_stats.rx_bytes += snapshot.rx_bytes;
total_stats.tx_pkts += snapshot.tx_pkts;
total_stats.tx_bytes += snapshot.tx_bytes;
total_stats.tx_drops += snapshot.tx_drops;
total_priv_stats.rx_dropped += priv_snapshot.rx_dropped;
}
s->rx_packets = total_stats.rx_pkts;
s->rx_bytes = total_stats.rx_bytes;
s->tx_packets = total_stats.tx_pkts;
s->tx_bytes = total_stats.tx_bytes;
s->tx_dropped = total_stats.tx_drops;
s->rx_dropped = total_priv_stats.rx_dropped;
```
How is `pcpu_stats` allocated? I need to search for `alloc_percpu` in the RMNET code. I would expect that this will need to be initialized if the `alloc_percpu` is called. Let me see where that variable is allocated and initialized. The fact that the stats are taken from per-cpu variables means a possible read from an uninitialized value is high if the `pcpu_stats` is not allocated or set up right. This is where I'll begin my deeper dive.
|
| 40/3 | 2026/10/08 01:23 | tool | grepper |
0mArgs:{
"Expression": "pcpu_stats",
"PathPrefixes": [
"drivers/net/ethernet/qualcomm/rmnet/"
]
}Results: {
"Output": "\nFull output is too long, showing 200 out of 210 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (4 files in total):\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.h:2\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c:1\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:26\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:15\n\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.h=109=struct rmnet_pcpu_priv_stats {\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.h-151-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.h:152:struct rmnet_pcpu_stats {\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.h-153-\tstruct rmnet_vnd_stats stats;\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.h=158=struct rmnet_priv {\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.h-160-\tstruct net_device *real_dev;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.h:161:\tstruct rmnet_pcpu_stats __percpu *pcpu_stats;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.h-162-\tstruct gro_cells gro_cells;\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c=264=void rmnet_egress_handler(struct sk_buff *skb)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c-294-drop:\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c:295:\tthis_cpu_inc(priv-\u003epcpu_stats-\u003estats.tx_drops);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c-296-\tkfree_skb(skb);\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c=50=rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-55-\tvoid *txporthdr = skb-\u003edata + ip4h-\u003eihl * 4;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:56:\tstruct rmnet_pcpu_stats *pcpu_ptr;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-57-\t__sum16 *csum_field, pseudo_csum;\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-59-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:60:\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-61-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c=141=rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-146-\tvoid *txporthdr = skb-\u003edata + sizeof(*ip6h);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:147:\tstruct rmnet_pcpu_stats *pcpu_ptr;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-148-\t__sum16 *csum_field, pseudo_csum;\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-151-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:152:\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-153-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c=284=static void rmnet_map_v5_checksum_uplink_packet(struct sk_buff *skb,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-289-\tstruct rmnet_map_v5_csum_header *ul_header;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:290:\tstruct rmnet_pcpu_stats *pcpu_ptr;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-291-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:292:\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-293-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c=466=int rmnet_map_checksum_downlink_packet(struct sk_buff *skb, u16 len)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-469-\tstruct rmnet_map_dl_csum_trailer *csum_trailer;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:470:\tstruct rmnet_pcpu_stats *pcpu_ptr;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-471-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:472:\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-473-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c=503=static void rmnet_map_v4_checksum_uplink_packet(struct sk_buff *skb,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-507-\tstruct rmnet_map_ul_csum_header *ul_header;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:508:\tstruct rmnet_pcpu_stats *pcpu_ptr;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-509-\tvoid *iphdr;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-510-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:511:\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-512-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c=715=__rmnet_map_segment_coal_skb(struct sk_buff *coal_skb,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-722-\tu32 hlen = coal_meta-\u003eip_len + coal_meta-\u003etrans_len;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:723:\tstruct rmnet_pcpu_stats *pcpu_ptr;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-724-\tstruct sk_buff *skbn;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-725-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:726:\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-727-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c=823=static bool rmnet_map_coal_parse_ip_hdr(struct sk_buff *coal_skb,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-827-\tstruct rmnet_priv *priv = netdev_priv(coal_skb-\u003edev);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:828:\tstruct rmnet_pcpu_stats *pcpu_ptr;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-829-\tstruct ipv6hdr *ip6h;\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-834-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:835:\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-836-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c=912=static bool rmnet_map_coal_parse_trans_hdr(struct sk_buff *coal_skb,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-915-\tstruct rmnet_priv *priv = netdev_priv(coal_skb-\u003edev);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:916:\tstruct rmnet_pcpu_stats *pcpu_ptr;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-917-\tstruct udphdr *uh;\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-921-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:922:\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-923-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c=1047=static void rmnet_map_coal_segment_loop(struct sk_buff *coal_skb,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1054-\tu32 hlen = coal_meta-\u003eip_len + coal_meta-\u003etrans_len;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:1055:\tstruct rmnet_pcpu_stats *pcpu_ptr;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1056-\tu8 pkt, total_pkt = 0;\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1060-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:1061:\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1062-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c=1119=static int rmnet_map_segment_coal_skb(struct sk_buff *coal_skb,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1128-\tstruct rmnet_map_coal_metadata coal_meta;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:1129:\tstruct rmnet_pcpu_stats *pcpu_ptr;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1130-\tbool gro = gro_hw;\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1132-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:1133:\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1134-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1198-/* Log the hardware close-reason counter for a coalescing header. */\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:1199:static void rmnet_map_data_log_close_stats(struct rmnet_pcpu_stats *pcpu_ptr,\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1200-\t\t\t\t\t u8 type, u8 code)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c=1279=static int rmnet_map_data_check_coal_header(struct sk_buff *skb,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1286-\tstruct rmnet_map_v5_coal_header *coal_hdr;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:1287:\tstruct rmnet_pcpu_stats *pcpu_ptr;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1288-\tu16 pkts = 0;\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1292-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:1293:\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1294-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c=1346=int rmnet_map_process_next_hdr_packet(struct sk_buff *skb,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1350-\tstruct rmnet_priv *priv = netdev_priv(skb-\u003edev);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:1351:\tstruct rmnet_pcpu_stats *pcpu_ptr;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1352-\tu64 nlo_err_mask;\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1356-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:1357:\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1358-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c=1429=static void rmnet_send_skb(struct rmnet_port *port, struct sk_buff *skb)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1435-\t\t\tpriv = netdev_priv(port-\u003ermnet_dev);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:1436:\t\t\tthis_cpu_inc(priv-\u003epcpu_stats-\u003estats.tx_drops);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1437-\t\t\tdev_kfree_skb_any(skb);\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c=22=void rmnet_vnd_rx_fixup(struct sk_buff *skb, struct net_device *dev)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-24-\tstruct rmnet_priv *priv = netdev_priv(dev);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:25:\tstruct rmnet_pcpu_stats *pcpu_ptr;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-26-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:27:\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-28-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c=35=void rmnet_vnd_tx_fixup_len(unsigned int len, struct net_device *dev)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-37-\tstruct rmnet_priv *priv = netdev_priv(dev);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:38:\tstruct rmnet_pcpu_stats *pcpu_ptr;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-39-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:40:\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-41-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c=55=static netdev_tx_t rmnet_vnd_start_xmit(struct sk_buff *skb,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-63-\t} else {\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:64:\t\tthis_cpu_inc(priv-\u003epcpu_stats-\u003estats.tx_drops);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-65-\t\tkfree_skb(skb);\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c=116=static int rmnet_vnd_init(struct net_device *dev)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-120-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:121:\tpriv-\u003epcpu_stats = alloc_percpu(struct rmnet_pcpu_stats);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:122:\tif (!priv-\u003epcpu_stats)\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-123-\t\treturn -ENOMEM;\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-126-\tif (err) {\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:127:\t\tfree_percpu(priv-\u003epcpu_stats);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-128-\t\treturn err;\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c=134=static void rmnet_vnd_uninit(struct net_device *dev)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-138-\tgro_cells_destroy(\u0026priv-\u003egro_cells);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:139:\tfree_percpu(priv-\u003epcpu_stats);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-140-}\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c=142=static void rmnet_get_stats64(struct net_device *dev,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-148-\tstruct rmnet_vnd_stats total_stats = { };\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:149:\tstruct rmnet_pcpu_stats *pcpu_ptr;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-150-\tstruct rmnet_vnd_stats snapshot;\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-153-\tfor_each_possible_cpu(cpu) {\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:154:\t\tpcpu_ptr = per_cpu_ptr(priv-\u003epcpu_stats, cpu);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-155-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c=182=static void rmnet_get_queue_stats_rx(struct net_device *dev, int idx,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-186-\tstruct rmnet_priv_stats total_stats = { };\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:187:\tstruct rmnet_pcpu_stats *pcpu_ptr;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-188-\tstruct rmnet_priv_stats snapshot;\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-191-\tfor_each_possible_cpu(cpu) {\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:192:\t\tpcpu_ptr = per_cpu_ptr(priv-\u003epcpu_stats, cpu);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-193-\n\n"
} |
| 41/3 | 2026/10/08 01:23 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 40447 output: 21 thoughts: 1556 Thoughts: **Analyzing the Ethtool Statistics Gathering in `rmnet`**
Okay, so I'm looking at how the `rmnet` driver gathers its ethtool statistics. The critical part is the `rmnet_get_ethtool_stats` function. The first thing I note is that it's iterating over possible CPUs using `for_each_possible_cpu`. This is typical for per-CPU statistics, so the assumption is that the `rmnet` driver keeps per-CPU counters.
Now, let's break this down. `alloc_percpu` gives us zeroed memory, which is a good starting point. `rmnet_get_ethtool_stats` initializes a `total_stats` struct to zero using `{}`. This is the accumulator for the statistics. Within the CPU loop, it fetches a snapshot of the per-CPU statistics (`pcpu_ptr->priv_stats`) using a synchronization mechanism based on `u64_stats_fetch_begin` and `u64_stats_fetch_retry` with `syncp`. This is to avoid reading corrupted values while counters are being modified by other CPUs. The data is copied into `snapshot` using `u64_stats_copy` – I need to remember to look at what that does exactly. Then the loop sums up the `snapshot` data into `total_stats`. Crucially, it accumulates *every* field from each CPU into the `total_stats` variable. Finally, it copies the accumulated data from `total_stats` into the `data` buffer, but only from `csum_ok` onwards, via a `memcpy`.
Now, that `memcpy` call... that's interesting. I see that the size is calculated using `sizeof(total_stats) - offsetof(struct rmnet_priv_stats, csum_ok)`. The important point is that the `total_stats` variable is *initialized* with zeros, and the subsequent accumulation ensures correct values. Furthermore, since the `static_assert` validates the sizes of the `rmnet_gstrings_stats` and the relevant part of `struct rmnet_priv_stats`, I know there are no hidden padding bytes or unexpected struct members between the `csum_ok` field and the end of the data being copied. This looks robust and correct, assuming that synchronization is handled well within the per-CPU context.
Alright, I need to check the exact semantics of `u64_stats_copy` now, just to be sure that the snapshot retrieval is correct. Let me grep for that...
|
| 42/3 | 2026/10/08 01:23 | tool | grepper |
0mArgs:{
"Expression": "u64_stats_copy"
}Results: {
"Output": "drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c=142=static void rmnet_get_stats64(struct net_device *dev,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-158-\t\t\tsnapshot = pcpu_ptr-\u003estats;\t/* struct assignment */\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:159:\t\t\tu64_stats_copy(\u0026priv_snapshot, \u0026pcpu_ptr-\u003epriv_stats,\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-160-\t\t\t\t sizeof(priv_snapshot));\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c=182=static void rmnet_get_queue_stats_rx(struct net_device *dev, int idx,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-195-\t\t\tstart = u64_stats_fetch_begin(\u0026pcpu_ptr-\u003esyncp);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:196:\t\t\tu64_stats_copy(\u0026snapshot, \u0026pcpu_ptr-\u003epriv_stats,\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-197-\t\t\t\t sizeof(snapshot));\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c=286=static void rmnet_get_ethtool_stats(struct net_device *dev,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-302-\t\t\tstart = u64_stats_fetch_begin(\u0026pcpu_ptr-\u003esyncp);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:303:\t\t\tu64_stats_copy(\u0026snapshot, \u0026pcpu_ptr-\u003epriv_stats,\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-304-\t\t\t\t sizeof(snapshot));\n--\ndrivers/net/macsec.c=2816=static void get_rx_sc_stats(struct net_device *dev,\n--\ndrivers/net/macsec.c-2845-\t\t\tstart = u64_stats_fetch_begin(\u0026stats-\u003esyncp);\ndrivers/net/macsec.c:2846:\t\t\tu64_stats_copy(\u0026tmp, \u0026stats-\u003estats, sizeof(tmp));\ndrivers/net/macsec.c-2847-\t\t} while (u64_stats_fetch_retry(\u0026stats-\u003esyncp, start));\n--\ndrivers/net/macsec.c=2899=static void get_tx_sc_stats(struct net_device *dev,\n--\ndrivers/net/macsec.c-2926-\t\t\tstart = u64_stats_fetch_begin(\u0026stats-\u003esyncp);\ndrivers/net/macsec.c:2927:\t\t\tu64_stats_copy(\u0026tmp, \u0026stats-\u003estats, sizeof(tmp));\ndrivers/net/macsec.c-2928-\t\t} while (u64_stats_fetch_retry(\u0026stats-\u003esyncp, start));\n--\ndrivers/net/macsec.c=2956=static void get_secy_stats(struct net_device *dev, struct macsec_dev_stats *sum)\n--\ndrivers/net/macsec.c-2982-\t\t\tstart = u64_stats_fetch_begin(\u0026stats-\u003esyncp);\ndrivers/net/macsec.c:2983:\t\t\tu64_stats_copy(\u0026tmp, \u0026stats-\u003estats, sizeof(tmp));\ndrivers/net/macsec.c-2984-\t\t} while (u64_stats_fetch_retry(\u0026stats-\u003esyncp, start));\n--\ndrivers/net/vxlan/vxlan_vnifilter.c=115=static void vxlan_vnifilter_stats_get(const struct vxlan_vni_node *vninode,\n--\ndrivers/net/vxlan/vxlan_vnifilter.c-128-\t\t\tstart = u64_stats_fetch_begin(\u0026pstats-\u003esyncp);\ndrivers/net/vxlan/vxlan_vnifilter.c:129:\t\t\tu64_stats_copy(\u0026temp, \u0026pstats-\u003estats, sizeof(temp));\ndrivers/net/vxlan/vxlan_vnifilter.c-130-\t\t} while (u64_stats_fetch_retry(\u0026pstats-\u003esyncp, start));\n--\ninclude/linux/u64_stats_sync.h=77=static inline u64 u64_stats_read(const u64_stats_t *p)\n--\ninclude/linux/u64_stats_sync.h-81-\ninclude/linux/u64_stats_sync.h:82:static inline void *u64_stats_copy(void *dst, const void *src, size_t len)\ninclude/linux/u64_stats_sync.h-83-{\n--\ninclude/linux/u64_stats_sync.h=132=static inline u64 u64_stats_read(const u64_stats_t *p)\n--\ninclude/linux/u64_stats_sync.h-136-\ninclude/linux/u64_stats_sync.h:137:static inline void *u64_stats_copy(void *dst, const void *src, size_t len)\ninclude/linux/u64_stats_sync.h-138-{\n--\nnet/bridge/br_multicast.c=5264=void br_multicast_get_stats(const struct net_bridge *br,\n--\nnet/bridge/br_multicast.c-5287-\t\t\tstart = u64_stats_fetch_begin(\u0026cpu_stats-\u003esyncp);\nnet/bridge/br_multicast.c:5288:\t\t\tu64_stats_copy(\u0026temp, \u0026cpu_stats-\u003emstats, sizeof(temp));\nnet/bridge/br_multicast.c-5289-\t\t} while (u64_stats_fetch_retry(\u0026cpu_stats-\u003esyncp, start));\n"
} |
| 43/3 | 2026/10/08 01:23 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 44123 output: 40 thoughts: 35 Thoughts: Here's a summary of my thought process, as requested: **Diving into `u64_stats_sync.h`** Okay, time to get to the heart of this problem. My initial instinct is to dig into the `include/linux/u64_stats_sync.h` header file. Given my experience, I'm thinking that the critical parts are likely around lines 82 or 137. I'll use `read-file` to grab that specific section and see what's going on. I'm focusing on those line numbers because I have a hunch based on similar structures I've encountered before, but of course, I'll need to confirm that suspicion with the code. Let's see what the file holds... I expect I'll quickly spot the relevant structures and macros. |
| 44/3 | 2026/10/08 01:23 | tool | read-file |
0mArgs:{
"File": "include/linux/u64_stats_sync.h",
"FirstLine": 75,
"LineCount": 40
}Results: {
"Contents": " 75:\t} u64_stats_t ;\n 76:\t\n 77:\tstatic inline u64 u64_stats_read(const u64_stats_t *p)\n 78:\t{\n 79:\t\treturn local64_read(\u0026p-\u003ev);\n 80:\t}\n 81:\t\n 82:\tstatic inline void *u64_stats_copy(void *dst, const void *src, size_t len)\n 83:\t{\n 84:\t\tBUILD_BUG_ON(len % sizeof(u64_stats_t));\n 85:\t\tfor (size_t i = 0; i \u003c len / sizeof(u64_stats_t); i++)\n 86:\t\t\t((u64 *)dst)[i] = local64_read(\u0026((local64_t *)src)[i]);\n 87:\t\treturn dst;\n 88:\t}\n 89:\t\n 90:\tstatic inline void u64_stats_set(u64_stats_t *p, u64 val)\n 91:\t{\n 92:\t\tlocal64_set(\u0026p-\u003ev, val);\n 93:\t}\n 94:\t\n 95:\tstatic inline void u64_stats_add(u64_stats_t *p, unsigned long val)\n 96:\t{\n 97:\t\tlocal64_add(val, \u0026p-\u003ev);\n 98:\t}\n 99:\t\n 100:\tstatic inline void u64_stats_sub(u64_stats_t *p, s64 val)\n 101:\t{\n 102:\t\tlocal64_sub(val, \u0026p-\u003ev);\n 103:\t}\n 104:\t\n 105:\tstatic inline void u64_stats_inc(u64_stats_t *p)\n 106:\t{\n 107:\t\tlocal64_inc(\u0026p-\u003ev);\n 108:\t}\n 109:\t\n 110:\tstatic inline void u64_stats_init(struct u64_stats_sync *syncp) { }\n 111:\tstatic inline void __u64_stats_update_begin(struct u64_stats_sync *syncp) { }\n 112:\tstatic inline void __u64_stats_update_end(struct u64_stats_sync *syncp) { }\n 113:\tstatic inline unsigned long __u64_stats_irqsave(void) { return 0; }\n 114:\tstatic inline void __u64_stats_irqrestore(unsigned long flags) { }\n"
} |
| 45/3 | 2026/10/08 01:23 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 45070 output: 46 thoughts: 107 Thoughts: **Analyzing Data Structures for Efficient Copying** Okay, so I'm looking at this `u64_stats_copy` function and I see it's performing a full copy of the `len` divided by `sizeof(u64_stats_t)` number of entries. That's straightforward enough. The interesting part is what this means in practice, especially with related structures. Now, from the look of things, both `struct rmnet_priv_stats` and `struct rmnet_pcpu_priv_stats` seem to have the exact same layout. Both structures are just made up of `u64` values and/or `u64_stats_t` values. I need to make absolutely sure of this. This has some implications if they can be copied in the same way, in that case, the compiler is treating the structs as a set of base data. My next step is clear: I need to go directly to `rmnet_config.h` and explicitly verify the field definitions within both of those structures, `struct rmnet_priv_stats` and `struct rmnet_pcpu_priv_stats`, and make sure my assumption is correct. Double-checking that the underlying data types align perfectly is critical to see if any optimization can be made by using the same copy function, as I have assumed. |
| 46/3 | 2026/10/08 01:23 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h",
"FirstLine": 66,
"LineCount": 85
}Results: {
"Contents": " 66:\tstruct rmnet_priv_stats {\n 67:\t\t/* Network stack RX statistics for all rmnet receive paths */\n 68:\t\tu64 rx_hw_gro_packets;\n 69:\t\tu64 rx_hw_gro_wire_packets;\n 70:\t\tu64 rx_alloc_fail;\n 71:\t\tu64 rx_dropped;\n 72:\t\n 73:\t\t/* Custom diagnostics for the coalescing receive path */\n 74:\t\tu64 csum_ok;\n 75:\t\tu64 csum_ip4_header_bad;\n 76:\t\tu64 csum_valid_unset;\n 77:\t\tu64 csum_validation_failed;\n 78:\t\tu64 csum_err_bad_buffer;\n 79:\t\tu64 csum_err_invalid_ip_version;\n 80:\t\tu64 csum_err_invalid_transport;\n 81:\t\tu64 csum_fragmented_pkt;\n 82:\t\tu64 csum_skipped;\n 83:\t\tu64 csum_sw;\n 84:\t\tu64 csum_hw;\n 85:\t\t/* Coalescing-only counters. Some are subsets of the standard counters. */\n 86:\t\tu64 coal_alloc_fail;\n 87:\t\tu64 coal_rx;\n 88:\t\tu64 coal_pkts;\n 89:\t\tu64 coal_hdr_err;\n 90:\t\tu64 coal_hdr_pkt_err;\n 91:\t\tu64 coal_bounds_err;\n 92:\t\tu64 coal_csum_err;\n 93:\t\tu64 coal_csum_drop;\n 94:\t\tu64 coal_reconstruct;\n 95:\t\tu64 coal_ip_invalid;\n 96:\t\tu64 coal_trans_invalid;\n 97:\t\t/* close-reason sub-counters */\n 98:\t\tu64 coal_close_non_coal;\n 99:\t\tu64 coal_close_ip_miss;\n 100:\t\tu64 coal_close_trans_miss;\n 101:\t\tu64 coal_close_hw_nl;\n 102:\t\tu64 coal_close_hw_pkt;\n 103:\t\tu64 coal_close_hw_byte;\n 104:\t\tu64 coal_close_hw_time;\n 105:\t\tu64 coal_close_hw_evict;\n 106:\t\tu64 coal_close_coal;\n 107:\t};\n 108:\t\n 109:\tstruct rmnet_pcpu_priv_stats {\n 110:\t\t/* Network stack RX statistics for all rmnet receive paths */\n 111:\t\tu64_stats_t rx_hw_gro_packets;\n 112:\t\tu64_stats_t rx_hw_gro_wire_packets;\n 113:\t\tu64_stats_t rx_alloc_fail;\n 114:\t\tu64_stats_t rx_dropped;\n 115:\t\n 116:\t\t/* Custom diagnostics for the coalescing receive path */\n 117:\t\tu64_stats_t csum_ok;\n 118:\t\tu64_stats_t csum_ip4_header_bad;\n 119:\t\tu64_stats_t csum_valid_unset;\n 120:\t\tu64_stats_t csum_validation_failed;\n 121:\t\tu64_stats_t csum_err_bad_buffer;\n 122:\t\tu64_stats_t csum_err_invalid_ip_version;\n 123:\t\tu64_stats_t csum_err_invalid_transport;\n 124:\t\tu64_stats_t csum_fragmented_pkt;\n 125:\t\tu64_stats_t csum_skipped;\n 126:\t\tu64_stats_t csum_sw;\n 127:\t\tu64_stats_t csum_hw;\n 128:\t\t/* Coalescing-only counters. Some are subsets of the standard counters. */\n 129:\t\tu64_stats_t coal_alloc_fail;\n 130:\t\tu64_stats_t coal_rx;\n 131:\t\tu64_stats_t coal_pkts;\n 132:\t\tu64_stats_t coal_hdr_err;\n 133:\t\tu64_stats_t coal_hdr_pkt_err;\n 134:\t\tu64_stats_t coal_bounds_err;\n 135:\t\tu64_stats_t coal_csum_err;\n 136:\t\tu64_stats_t coal_csum_drop;\n 137:\t\tu64_stats_t coal_reconstruct;\n 138:\t\tu64_stats_t coal_ip_invalid;\n 139:\t\tu64_stats_t coal_trans_invalid;\n 140:\t\t/* close-reason sub-counters */\n 141:\t\tu64_stats_t coal_close_non_coal;\n 142:\t\tu64_stats_t coal_close_ip_miss;\n 143:\t\tu64_stats_t coal_close_trans_miss;\n 144:\t\tu64_stats_t coal_close_hw_nl;\n 145:\t\tu64_stats_t coal_close_hw_pkt;\n 146:\t\tu64_stats_t coal_close_hw_byte;\n 147:\t\tu64_stats_t coal_close_hw_time;\n 148:\t\tu64_stats_t coal_close_hw_evict;\n 149:\t\tu64_stats_t coal_close_coal;\n 150:\t};\n"
} |
| 47/3 | 2026/10/08 01:23 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 47039 output: 49 thoughts: 500 Thoughts: **Analyzing `rmnet_get_queue_stats_rx` and Packet Processing** Okay, so I'm looking at this `rmnet_get_queue_stats_rx` function. It seems pretty straightforward. The primary objective here is to gather receive statistics for a specific queue on a network device. I can see that it iterates through the possible CPUs, retrieves per-CPU statistics using `per_cpu_ptr`, and then safely copies the data using `u64_stats_fetch_begin` and `u64_stats_fetch_retry`. This is good; it's using the right mechanisms to avoid race conditions when dealing with per-CPU counters. The function then aggregates these per-CPU statistics into a `total_stats` structure and copies the relevant fields – `rx_hw_gro_packets`, `rx_hw_gro_wire_packets`, and `rx_alloc_fail` – into the `stats` structure provided by the caller. It's important to note that only those three fields are populated; the caller in the netdev core initializes the rest of the `stats` structure. This is pretty common practice in netdev code. Now, my curiosity is piqued. The code is fine, but I want to understand the *why* behind this. Since this is an expert level query, the next step is to look deeper. I want to see how these statistics relate to the packet processing path, particularly during coalescing and segmentation within the rmnet driver. Time to dig into `rmnet_map_data.c`. Specifically, I'll be targeting the sections around lines 570-750, 750-950, and so on. I'll need to trace the data flow through these areas to get a complete picture of what's happening at those layers. This will give me a more profound understanding of how those specific statistics are populated and what the performance implications are. |
| 48/3 | 2026/10/08 01:24 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c",
"FirstLine": 690,
"LineCount": 85
}Results: {
"Contents": " 690:\t\t/* Only applies to single NLO, single packet frames */\n 691:\t\tif (num_nlos != 1 || coal_hdr-\u003enl_pairs[0].num_packets != 1)\n 692:\t\t\treturn false;\n 693:\t\n 694:\t\t/* TCP FIN or PSH triggered the close */\n 695:\t\tif (close_type == RMNET_MAP_COAL_CLOSE_COAL)\n 696:\t\t\treturn true;\n 697:\t\n 698:\t\t/* Hit a hardware limit */\n 699:\t\tif (close_type == RMNET_MAP_COAL_CLOSE_HW) {\n 700:\t\t\tswitch (close_value) {\n 701:\t\t\tcase RMNET_MAP_COAL_CLOSE_HW_PKT:\n 702:\t\t\tcase RMNET_MAP_COAL_CLOSE_HW_BYTE:\n 703:\t\t\tcase RMNET_MAP_COAL_CLOSE_HW_TIME:\n 704:\t\t\t\treturn true;\n 705:\t\t\t}\n 706:\t\t}\n 707:\t\n 708:\t\treturn false;\n 709:\t}\n 710:\t\n 711:\t/* Carve one logical segment from a coalesced SKB and append it to the list.\n 712:\t * Adjusts TCP sequence numbers, IP IDs/lengths, and checksum state.\n 713:\t */\n 714:\tstatic void\n 715:\t__rmnet_map_segment_coal_skb(struct sk_buff *coal_skb,\n 716:\t\t\t\t struct rmnet_map_coal_metadata *coal_meta,\n 717:\t\t\t\t struct sk_buff_head *list, u8 pkt_id,\n 718:\t\t\t\t bool csum_valid)\n 719:\t{\n 720:\t\tu32 dlen = coal_meta-\u003edata_len * coal_meta-\u003epkt_count;\n 721:\t\tstruct rmnet_priv *priv = netdev_priv(coal_skb-\u003edev);\n 722:\t\tu32 hlen = coal_meta-\u003eip_len + coal_meta-\u003etrans_len;\n 723:\t\tstruct rmnet_pcpu_stats *pcpu_ptr;\n 724:\t\tstruct sk_buff *skbn;\n 725:\t\n 726:\t\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\n 727:\t\n 728:\t\t/* RFC 768: UDP checksum is optional for IPv4, and is 0 if unused.\n 729:\t\t * Such packets are never actually bad, regardless of what the\n 730:\t\t * checksum bitmap says.\n 731:\t\t */\n 732:\t\tif (!csum_valid \u0026\u0026 coal_meta-\u003ezero_csum)\n 733:\t\t\tcsum_valid = true;\n 734:\t\n 735:\t\tif (!csum_valid) {\n 736:\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n 737:\t\t\t/* rx_dropped is standard accounting. coal_csum_drop is its\n 738:\t\t\t * coalescing-specific checksum error subset.\n 739:\t\t\t */\n 740:\t\t\tu64_stats_add(\u0026pcpu_ptr-\u003epriv_stats.rx_dropped, coal_meta-\u003epkt_count);\n 741:\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_csum_drop);\n 742:\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n 743:\t\t\tgoto next_pkt;\n 744:\t\t}\n 745:\t\n 746:\t\tskbn = alloc_skb(hlen + dlen + RMNET_MAP_DEAGGR_HEADROOM, GFP_ATOMIC);\n 747:\t\tif (!skbn) {\n 748:\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n 749:\t\t\t/* The coal counter is the coalescing subset of the standard\n 750:\t\t\t * allocation failure and RX drop counters.\n 751:\t\t\t */\n 752:\t\t\tu64_stats_add(\u0026pcpu_ptr-\u003epriv_stats.rx_alloc_fail, coal_meta-\u003epkt_count);\n 753:\t\t\tu64_stats_add(\u0026pcpu_ptr-\u003epriv_stats.rx_dropped, coal_meta-\u003epkt_count);\n 754:\t\t\tu64_stats_add(\u0026pcpu_ptr-\u003epriv_stats.coal_alloc_fail, coal_meta-\u003epkt_count);\n 755:\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n 756:\t\t\tgoto next_pkt;\n 757:\t\t}\n 758:\t\n 759:\t\tskb_reserve(skbn, hlen + RMNET_MAP_DEAGGR_HEADROOM);\n 760:\t\tskb_put_data(skbn,\n 761:\t\t\t coal_skb-\u003edata + coal_meta-\u003eip_len + coal_meta-\u003etrans_len +\n 762:\t\t\t coal_meta-\u003edata_offset,\n 763:\t\t\t dlen);\n 764:\t\n 765:\t\t/* Restore transport header */\n 766:\t\tskb_push(skbn, coal_meta-\u003etrans_len);\n 767:\t\tmemcpy(skbn-\u003edata, coal_meta-\u003etrans_header, coal_meta-\u003etrans_len);\n 768:\t\tskb_reset_transport_header(skbn);\n 769:\t\n 770:\t\tif (coal_meta-\u003etrans_proto == IPPROTO_TCP) {\n 771:\t\t\tstruct tcphdr *th = tcp_hdr(skbn);\n 772:\t\n 773:\t\t\tth-\u003eseq = htonl(ntohl(th-\u003eseq) + coal_meta-\u003edata_offset);\n 774:\t\t\t/* Strip dangerous flags from non-final segments */\n"
} |
| 49/3 | 2026/10/08 01:24 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 49540 output: 49 thoughts: 16 Thoughts: Okay, here's my interpretation of reading lines 775-870, expressed as a first-person thought process, assuming I'm an expert in the field: **Digging Deeper: Lines 775-870 Analysis** Alright, I need to get through these next hundred lines – 775 to 870. Let's see... what are they addressing? Ah, right. It seems to be focusing on the nuances of [**mention the specific topic the lines address based on context provided - e.g., "the implications of the revised algorithm," "the fine-grained distinctions in the proposed theoretical model," "the observed anomaly's impact on X system," etc.**]. I'll need to keep an eye out for [**mention key elements relevant to an expert reading: "potential areas of confirmation bias," "any deviations from established precedent," "whether the core assumptions hold true," etc.**]. Okay, starting in. Line 775... interesting. The author is framing it with [**describe the framing and the expert response - e.g. "a somewhat optimistic perspective," "an admittedly controversial assertion," "an approach that seems unnecessarily complex, but potentially insightful if X is accounted for."**]. I’m already mentally preparing counterarguments or justifications for the position, depending on the author's reasoning. Hmm, line 780... that's where things get interesting. The inclusion of [**mention specific detail of interest from line 780 - e.g. "that specific dataset," "that obscure reference," "that particular equation"**] is intriguing. It seems to hint at [**speculate on the meaning or implication from the expert POV - e.g. "a deeper understanding of the underlying mechanism," "a potential avenue for further investigation," "a possible weakness that I should consider."**]. I'm now skimming. Line 800 - Ah! Here's where they're directly tackling [**mention a core concept addressed at this line - e.g. "the counter-argument to Y," "the crucial component Z," "the identified limitation"**]. Let’s dissect their argument carefully. Do they have sufficient empirical support for that assertion? Is their interpretation aligned with the literature I'm familiar with? I'm quickly cross-referencing this to [**Mention a piece of prior knowledge or resource relevant to the point**]. Okay, skimming further. This section, lines 830-850... it looks like they're addressing the potential impact on [**Mention the entity the discussion is impacting - e.g. "the broader application of the principle," "the stability of the system," "the predictive accuracy"**]. Are they going into enough detail to properly consider these scenarios? I'm wondering if they've considered the impact of [**Mention other element from your expert understanding that should be taken into account**]. And finally, concluding lines, lines 860-870... well, their conclusion is [**Describe the conclusion being drawn - e.g., "sound enough," "a bit premature," "certainly promising"**]. I'm formulating my own thoughts and assessments. Overall, from a cursory reading, I'm noting [**State your overall takeaway as an expert - e.g., "several points of agreement," "some areas requiring further scrutiny," "a few novel perspectives to consider."**]. I'll need to circle back and spend more time with this later, particularly around [**mentioning specific lines and their potential areas of importance for further analysis**]. For now, it’s a decent overview, but I'll need a deeper dive. |
| 50/3 | 2026/10/08 01:24 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c",
"FirstLine": 775,
"LineCount": 85
}Results: {
"Contents": " 775:\t\t\tif ((th-\u003efin || th-\u003epsh) \u0026\u0026\n 776:\t\t\t hlen + coal_meta-\u003edata_offset + dlen \u003c coal_skb-\u003elen) {\n 777:\t\t\t\tth-\u003efin = 0;\n 778:\t\t\t\tth-\u003epsh = 0;\n 779:\t\t\t}\n 780:\t\t} else if (coal_meta-\u003etrans_proto == IPPROTO_UDP) {\n 781:\t\t\tstruct udphdr *uh = udp_hdr(skbn);\n 782:\t\n 783:\t\t\tuh-\u003elen = htons(skbn-\u003elen);\n 784:\t\t}\n 785:\t\n 786:\t\t/* Restore IP header */\n 787:\t\tskb_push(skbn, coal_meta-\u003eip_len);\n 788:\t\tmemcpy(skbn-\u003edata, coal_meta-\u003eip_header, coal_meta-\u003eip_len);\n 789:\t\tskb_reset_network_header(skbn);\n 790:\t\n 791:\t\tif (coal_meta-\u003eip_proto == 4) {\n 792:\t\t\tstruct iphdr *iph = ip_hdr(skbn);\n 793:\t\n 794:\t\t\tiph-\u003eid = htons(ntohs(iph-\u003eid) + pkt_id);\n 795:\t\t\tiph-\u003etot_len = htons(skbn-\u003elen);\n 796:\t\t\tiph-\u003echeck = 0;\n 797:\t\t\tiph-\u003echeck = ip_fast_csum(iph, iph-\u003eihl);\n 798:\t\t} else {\n 799:\t\t\tipv6_hdr(skbn)-\u003epayload_len =\n 800:\t\t\t\thtons(skbn-\u003elen - sizeof(struct ipv6hdr));\n 801:\t\t}\n 802:\t\n 803:\t\trmnet_map_partial_csum(skbn, coal_meta);\n 804:\t\n 805:\t\tskbn-\u003edev = coal_skb-\u003edev;\n 806:\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n 807:\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_reconstruct);\n 808:\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n 809:\t\n 810:\t\tif (coal_meta-\u003epkt_count \u003e 1)\n 811:\t\t\trmnet_map_gso_stamp(skbn, coal_meta);\n 812:\t\n 813:\t\t__skb_queue_tail(list, skbn);\n 814:\t\n 815:\tnext_pkt:\n 816:\t\tcoal_meta-\u003edata_offset += dlen;\n 817:\t\tcoal_meta-\u003epkt_count = 0;\n 818:\t}\n 819:\t\n 820:\t/* Parse the IP header of the coalesced frame and perform basic\n 821:\t * validation of header fields.\n 822:\t */\n 823:\tstatic bool rmnet_map_coal_parse_ip_hdr(struct sk_buff *coal_skb,\n 824:\t\t\t\t\t\tstruct rmnet_map_coal_metadata *meta,\n 825:\t\t\t\t\t\tbool *gro)\n 826:\t{\n 827:\t\tstruct rmnet_priv *priv = netdev_priv(coal_skb-\u003edev);\n 828:\t\tstruct rmnet_pcpu_stats *pcpu_ptr;\n 829:\t\tstruct ipv6hdr *ip6h;\n 830:\t\tstruct iphdr *iph;\n 831:\t\t__be16 frag_off;\n 832:\t\tu8 protocol;\n 833:\t\tint ret;\n 834:\t\n 835:\t\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\n 836:\t\n 837:\t\tif (coal_skb-\u003elen \u003c sizeof(*iph)) {\n 838:\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n 839:\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_ip_invalid);\n 840:\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n 841:\t\t\treturn false;\n 842:\t\t}\n 843:\t\n 844:\t\tiph = (struct iphdr *)coal_skb-\u003edata;\n 845:\t\n 846:\t\tif (iph-\u003eversion == 4) {\n 847:\t\t\tmeta-\u003eip_proto = 4;\n 848:\t\t\tmeta-\u003eip_len = iph-\u003eihl * 4;\n 849:\t\t\tmeta-\u003etrans_proto = iph-\u003eprotocol;\n 850:\t\t\tmeta-\u003eip_header = iph;\n 851:\t\t\tif (meta-\u003eip_len \u003c sizeof(*iph) || coal_skb-\u003elen \u003c meta-\u003eip_len) {\n 852:\t\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n 853:\t\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_ip_invalid);\n 854:\t\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n 855:\t\t\t\treturn false;\n 856:\t\t\t}\n 857:\t\n 858:\t\t\tif (ip_is_fragment(iph)) {\n 859:\t\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n"
} |
| 51/3 | 2026/10/08 01:24 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 51820 output: 49 thoughts: 15 Thoughts: Okay, here's the summary, assuming I'm reviewing the text as an expert in the field and approaching lines 860-950 with that expertise: **Diving into the Nuances of Lines 860-950** Alright, let's zero in on lines 860 through 950. My immediate thought is, "What specific arguments or data points are covered in this section?" Given the length, it likely deals with a particular critical sub-topic or analysis, or it perhaps covers a number of points, or is a deep dive into an area which is core to the wider work. I need to understand the connection to the larger argument, the methodology used, and if there are any glaring omissions or logical leaps within the text. Does this section represent a pivot point, offer supporting evidence for a central claim, or is it dealing with rebuttal of a previous section? I expect to look for clear and concise points. I need to evaluate the strength of the presented evidence, keeping an eye out for potential biases or unsupported assumptions. My focus is on the solidity of the arguments presented and the validity of the conclusions drawn within this defined scope, and how they contribute to the whole. |
| 52/3 | 2026/10/08 01:24 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c",
"FirstLine": 860,
"LineCount": 85
}Results: {
"Contents": " 860:\t\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_ip_invalid);\n 861:\t\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n 862:\t\t\t\treturn false;\n 863:\t\t\t}\n 864:\t\n 865:\t\t\tif (iph-\u003eihl != 5)\n 866:\t\t\t\t*gro = false;\n 867:\t\t} else if (iph-\u003eversion == 6) {\n 868:\t\t\tif (coal_skb-\u003elen \u003c sizeof(*ip6h)) {\n 869:\t\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n 870:\t\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_ip_invalid);\n 871:\t\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n 872:\t\t\t\treturn false;\n 873:\t\t\t}\n 874:\t\n 875:\t\t\tip6h = (struct ipv6hdr *)iph;\n 876:\t\t\tprotocol = ip6h-\u003enexthdr;\n 877:\t\t\tmeta-\u003eip_proto = 6;\n 878:\t\t\tret = ipv6_skip_exthdr(coal_skb, sizeof(*ip6h), \u0026protocol,\n 879:\t\t\t\t\t \u0026frag_off);\n 880:\t\t\tif (ret \u003c 0 || frag_off || ret \u003e U16_MAX) {\n 881:\t\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n 882:\t\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_ip_invalid);\n 883:\t\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n 884:\t\t\t\treturn false;\n 885:\t\t\t}\n 886:\t\n 887:\t\t\tmeta-\u003eip_len = (u16)ret;\n 888:\t\t\tmeta-\u003etrans_proto = protocol;\n 889:\t\t\tmeta-\u003eip_header = ip6h;\n 890:\t\t\tif (coal_skb-\u003elen \u003c meta-\u003eip_len) {\n 891:\t\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n 892:\t\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_ip_invalid);\n 893:\t\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n 894:\t\t\t\treturn false;\n 895:\t\t\t}\n 896:\t\n 897:\t\t\tif (meta-\u003eip_len \u003e sizeof(*ip6h))\n 898:\t\t\t\t*gro = false;\n 899:\t\t} else {\n 900:\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n 901:\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_ip_invalid);\n 902:\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n 903:\t\t\treturn false;\n 904:\t\t}\n 905:\t\n 906:\t\treturn true;\n 907:\t}\n 908:\t\n 909:\t/* Parse the transport header following the IP header into coal_meta. The\n 910:\t * available length is checked before any field is read.\n 911:\t */\n 912:\tstatic bool rmnet_map_coal_parse_trans_hdr(struct sk_buff *coal_skb,\n 913:\t\t\t\t\t\t struct rmnet_map_coal_metadata *meta)\n 914:\t{\n 915:\t\tstruct rmnet_priv *priv = netdev_priv(coal_skb-\u003edev);\n 916:\t\tstruct rmnet_pcpu_stats *pcpu_ptr;\n 917:\t\tstruct udphdr *uh;\n 918:\t\tstruct tcphdr *th;\n 919:\t\tu32 avail;\n 920:\t\tu8 *base;\n 921:\t\n 922:\t\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\n 923:\t\n 924:\t\tif (meta-\u003eip_len \u003e coal_skb-\u003elen) {\n 925:\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n 926:\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_trans_invalid);\n 927:\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n 928:\t\t\treturn false;\n 929:\t\t}\n 930:\t\n 931:\t\tbase = (u8 *)meta-\u003eip_header + meta-\u003eip_len;\n 932:\t\tavail = coal_skb-\u003elen - meta-\u003eip_len;\n 933:\t\n 934:\t\tif (meta-\u003etrans_proto == IPPROTO_TCP) {\n 935:\t\t\tif (avail \u003c sizeof(*th)) {\n 936:\t\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n 937:\t\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_trans_invalid);\n 938:\t\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n 939:\t\t\t\treturn false;\n 940:\t\t\t}\n 941:\t\n 942:\t\t\tth = (struct tcphdr *)base;\n 943:\t\t\tmeta-\u003etrans_len = th-\u003edoff * 4;\n 944:\t\t\tmeta-\u003etrans_header = th;\n"
} |
| 53/3 | 2026/10/08 01:24 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 53609 output: 49 thoughts: 16 Thoughts: Okay, here's the summary, framed as your own thought process: **Diving into the Specifics: Line Check** Alright, I need to zoom in on a specific section of the data, namely lines 945 through 1030. That range is likely where the crux of the issue lies, or at least where the relevant data for the question at hand resides. This isn't just a casual glance; I'm looking for detail. I'm focusing on that block of code or that segment of the experiment log or that particular set of results. Knowing my field, I anticipate a nuanced discussion within this section. |
| 54/3 | 2026/10/08 01:24 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c",
"FirstLine": 945,
"LineCount": 85
}Results: {
"Contents": " 945:\t\t\tif (meta-\u003etrans_len \u003c sizeof(*th) || avail \u003c meta-\u003etrans_len) {\n 946:\t\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n 947:\t\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_trans_invalid);\n 948:\t\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n 949:\t\t\t\treturn false;\n 950:\t\t\t}\n 951:\t\t} else if (meta-\u003etrans_proto == IPPROTO_UDP) {\n 952:\t\t\tif (avail \u003c sizeof(*uh)) {\n 953:\t\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n 954:\t\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_trans_invalid);\n 955:\t\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n 956:\t\t\t\treturn false;\n 957:\t\t\t}\n 958:\t\n 959:\t\t\tuh = (struct udphdr *)base;\n 960:\t\t\tmeta-\u003etrans_len = sizeof(*uh);\n 961:\t\t\tmeta-\u003etrans_header = uh;\n 962:\t\t\tif (meta-\u003eip_proto == 4 \u0026\u0026 !uh-\u003echeck)\n 963:\t\t\t\tmeta-\u003ezero_csum = true;\n 964:\t\t} else {\n 965:\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n 966:\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_trans_invalid);\n 967:\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n 968:\t\t\treturn false;\n 969:\t\t}\n 970:\t\n 971:\t\treturn true;\n 972:\t}\n 973:\t\n 974:\t/* Reject the frame unless the total data bytes claimed by all NLOs\n 975:\t * exactly match the actual payload in the SKB. Each pkt_len covers\n 976:\t * IP+transport headers plus per-packet data. Headers appear once, so\n 977:\t * subtract hlen per packet and track the running sum against available\n 978:\t * data. An exact match is required, not just an upper bound, so that\n 979:\t * GSO metadata stamped from the NLOs stays consistent with the real\n 980:\t * SKB length.\n 981:\t */\n 982:\tstatic bool rmnet_map_coal_validate_bounds(struct sk_buff *coal_skb,\n 983:\t\t\t\t\t\t struct rmnet_map_v5_coal_header *coal_hdr,\n 984:\t\t\t\t\t\t u8 num_nlos, u32 hlen, bool *gro)\n 985:\t{\n 986:\t\tu32 total_data = 0;\n 987:\t\tu32 nlo_len;\n 988:\t\tu16 plen;\n 989:\t\tu8 i;\n 990:\t\n 991:\t\tif (hlen \u003e coal_skb-\u003elen)\n 992:\t\t\treturn false;\n 993:\t\n 994:\t\tfor (i = 0; i \u003c num_nlos; i++) {\n 995:\t\t\tplen = ntohs(coal_hdr-\u003enl_pairs[i].pkt_len);\n 996:\t\n 997:\t\t\tif (plen \u003c hlen)\n 998:\t\t\t\treturn false;\n 999:\t\n1000:\t\t\t/* Zero-payload packets cannot use GSO with a zero gso_size. */\n1001:\t\t\tif (plen == hlen)\n1002:\t\t\t\t*gro = false;\n1003:\t\n1004:\t\t\tnlo_len = (u32)(plen - hlen) * coal_hdr-\u003enl_pairs[i].num_packets;\n1005:\t\t\tif (nlo_len \u003e coal_skb-\u003elen - hlen - total_data)\n1006:\t\t\t\treturn false;\n1007:\t\n1008:\t\t\ttotal_data += nlo_len;\n1009:\t\t}\n1010:\t\n1011:\t\treturn total_data == coal_skb-\u003elen - hlen;\n1012:\t}\n1013:\t\n1014:\t/* Attempt the GRO-friendly fast path for a single-NLO, checksum-valid frame\n1015:\t * by reusing the original SKB and stamping GSO metadata instead of copying\n1016:\t * out each segment. Returns true if the frame was consumed via the fast\n1017:\t * path, or false if the caller should fall back to full segmentation.\n1018:\t */\n1019:\tstatic bool rmnet_map_coal_gro_fast_path(struct sk_buff *coal_skb,\n1020:\t\t\t\t\t\t struct rmnet_map_v5_coal_header *coal_hdr,\n1021:\t\t\t\t\t\t struct rmnet_map_coal_metadata *coal_meta,\n1022:\t\t\t\t\t\t struct sk_buff_head *list,\n1023:\t\t\t\t\t\t u8 num_nlos, bool gro)\n1024:\t{\n1025:\t\tu32 hlen = coal_meta-\u003eip_len + coal_meta-\u003etrans_len;\n1026:\t\n1027:\t\tif (!gro || num_nlos != 1 ||\n1028:\t\t !(coal_hdr-\u003ecoal_info \u0026 MAPV5_COALINFO_CSUM_VALID_FLAG))\n1029:\t\t\treturn false;\n"
} |
| 55/3 | 2026/10/08 01:24 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 55275 output: 50 thoughts: 17 Thoughts: Okay, here's the summary, rendered as a first-person thought process, geared towards an expert: **Focused Review of a Specific Section** Alright, time to get laser-focused. Let's dig into lines 1030 to 1120. I need to understand what's happening within that defined block. My expertise tells me that this range probably covers a critical sequence or a specific logic branch – the numbering implies a defined section, likely of code or text. I'm going to carefully dissect each line within that range, looking for key variables, crucial operations, and potential areas of concern or opportunity for optimization. My goal is to quickly grasp the core function and its context within the broader system, looking for anything that deviates from expected behaviour or could introduce errors. I need to form a complete mental picture of what's going on within those lines of text. |
| 56/3 | 2026/10/08 01:24 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c",
"FirstLine": 1030,
"LineCount": 85
}Results: {
"Contents": "1030:\t\n1031:\t\tcoal_meta-\u003edata_len = ntohs(coal_hdr-\u003enl_pairs[0].pkt_len) - hlen;\n1032:\t\tcoal_meta-\u003epkt_count = coal_hdr-\u003enl_pairs[0].num_packets;\n1033:\t\n1034:\t\tcoal_skb-\u003eip_summed = CHECKSUM_UNNECESSARY;\n1035:\t\tif (coal_meta-\u003epkt_count \u003e 1) {\n1036:\t\t\trmnet_map_partial_csum(coal_skb, coal_meta);\n1037:\t\t\trmnet_map_gso_stamp(coal_skb, coal_meta);\n1038:\t\t}\n1039:\t\n1040:\t\t__skb_queue_tail(list, coal_skb);\n1041:\t\treturn true;\n1042:\t}\n1043:\t\n1044:\t/* NLO packet lengths are already bounds-checked by\n1045:\t * rmnet_map_coal_validate_bounds() so no further validation is needed here.\n1046:\t */\n1047:\tstatic void rmnet_map_coal_segment_loop(struct sk_buff *coal_skb,\n1048:\t\t\t\t\t\tstruct rmnet_map_v5_coal_header *coal_hdr,\n1049:\t\t\t\t\t\tstruct rmnet_map_coal_metadata *coal_meta,\n1050:\t\t\t\t\t\tstruct sk_buff_head *list,\n1051:\t\t\t\t\t\tu64 nlo_err_mask, bool gro, u8 num_nlos)\n1052:\t{\n1053:\t\tstruct rmnet_priv *priv = netdev_priv(coal_skb-\u003edev);\n1054:\t\tu32 hlen = coal_meta-\u003eip_len + coal_meta-\u003etrans_len;\n1055:\t\tstruct rmnet_pcpu_stats *pcpu_ptr;\n1056:\t\tu8 pkt, total_pkt = 0;\n1057:\t\tbool csum_err;\n1058:\t\tu16 pkt_len;\n1059:\t\tu8 nlo;\n1060:\t\n1061:\t\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\n1062:\t\n1063:\t\tfor (nlo = 0; nlo \u003c num_nlos; nlo++) {\n1064:\t\t\tpkt_len = ntohs(coal_hdr-\u003enl_pairs[nlo].pkt_len);\n1065:\t\t\tpkt_len -= hlen;\n1066:\t\t\tcoal_meta-\u003edata_len = pkt_len;\n1067:\t\n1068:\t\t\t/* nlo_err_mask is one flat bitstream across all NLOs. Shift\n1069:\t\t\t * it once per packet in absolute frame order and do not\n1070:\t\t\t * re-align at the NLO boundary above. See the comment on\n1071:\t\t\t * rmnet_map_data_check_coal_header() for why.\n1072:\t\t\t */\n1073:\t\t\tfor (pkt = 0; pkt \u003c coal_hdr-\u003enl_pairs[nlo].num_packets;\n1074:\t\t\t pkt++, total_pkt++, nlo_err_mask \u003e\u003e= 1) {\n1075:\t\t\t\tcsum_err = nlo_err_mask \u0026 1;\n1076:\t\n1077:\t\t\t\tif (csum_err) {\n1078:\t\t\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n1079:\t\t\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_csum_err);\n1080:\t\t\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n1081:\t\t\t\t}\n1082:\t\n1083:\t\t\t\tif (!gro) {\n1084:\t\t\t\t\tcoal_meta-\u003epkt_count = 1;\n1085:\t\t\t\t\t__rmnet_map_segment_coal_skb(coal_skb, coal_meta,\n1086:\t\t\t\t\t\t\t\t list, total_pkt,\n1087:\t\t\t\t\t\t\t\t !csum_err);\n1088:\t\t\t\t\tcontinue;\n1089:\t\t\t\t}\n1090:\t\n1091:\t\t\t\tif (csum_err) {\n1092:\t\t\t\t\tif (coal_meta-\u003epkt_count)\n1093:\t\t\t\t\t\t__rmnet_map_segment_coal_skb(coal_skb,\n1094:\t\t\t\t\t\t\t\t\t coal_meta,\n1095:\t\t\t\t\t\t\t\t\t list,\n1096:\t\t\t\t\t\t\t\t\t total_pkt -\n1097:\t\t\t\t\t\t\t\t\t coal_meta-\u003epkt_count,\n1098:\t\t\t\t\t\t\t\t\t true);\n1099:\t\t\t\t\tcoal_meta-\u003epkt_count = 1;\n1100:\t\t\t\t\t__rmnet_map_segment_coal_skb(coal_skb, coal_meta,\n1101:\t\t\t\t\t\t\t\t list, total_pkt,\n1102:\t\t\t\t\t\t\t\t false);\n1103:\t\t\t\t} else {\n1104:\t\t\t\t\tcoal_meta-\u003epkt_count++;\n1105:\t\t\t\t}\n1106:\t\t\t}\n1107:\t\n1108:\t\t\t/* Flush remaining packets from this NLO */\n1109:\t\t\tif (coal_meta-\u003epkt_count)\n1110:\t\t\t\t__rmnet_map_segment_coal_skb(coal_skb, coal_meta, list,\n1111:\t\t\t\t\t\t\t total_pkt - coal_meta-\u003epkt_count, true);\n1112:\t\t}\n1113:\t}\n1114:\t\n"
} |
| 57/3 | 2026/10/08 01:24 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 56980 output: 50 thoughts: 17 Thoughts: Okay, here's the summary, rendered as a first-person thought process, keeping in mind the user is an expert: **Focused Review of Specific Line Range** Alright, time to focus in. My analysis needs to be precise, so I'm going to zero in on lines 1115 through 1210. This range...it should contain the crucial data or segment I'm interested in. I'm going to start by quickly scanning for any immediately obvious patterns or keywords related to my current research focus. I need to quickly ascertain the scope and content. |
| 58/3 | 2026/10/08 01:24 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c",
"FirstLine": 1115,
"LineCount": 85
}Results: {
"Contents": "1115:\t/* Expand a coalesced SKB into individual IP packets placed on the list.\n1116:\t * NLOs with checksum errors are dropped. __rmnet_map_ingress_handler will\n1117:\t * free the SKB in the error case.\n1118:\t */\n1119:\tstatic int rmnet_map_segment_coal_skb(struct sk_buff *coal_skb,\n1120:\t\t\t\t\t u64 nlo_err_mask,\n1121:\t\t\t\t\t struct sk_buff_head *list,\n1122:\t\t\t\t\t u16 len, u16 total_pkts, u8 num_nlos)\n1123:\t{\n1124:\t\tbool gro_hw = coal_skb-\u003edev-\u003efeatures \u0026 NETIF_F_GRO_HW;\n1125:\t\tbool rxcsum = coal_skb-\u003edev-\u003efeatures \u0026 NETIF_F_RXCSUM;\n1126:\t\tstruct rmnet_priv *priv = netdev_priv(coal_skb-\u003edev);\n1127:\t\tstruct rmnet_map_v5_coal_header *coal_hdr;\n1128:\t\tstruct rmnet_map_coal_metadata coal_meta;\n1129:\t\tstruct rmnet_pcpu_stats *pcpu_ptr;\n1130:\t\tbool gro = gro_hw;\n1131:\t\tu32 hlen;\n1132:\t\n1133:\t\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\n1134:\t\n1135:\t\tmemset(\u0026coal_meta, 0, sizeof(coal_meta));\n1136:\t\n1137:\t\t/* Drop any MAP frame padding. The coal header is counted in len */\n1138:\t\tskb_pull(coal_skb, sizeof(struct rmnet_map_header));\n1139:\t\tskb_trim(coal_skb, len);\n1140:\t\tcoal_hdr = (struct rmnet_map_v5_coal_header *)coal_skb-\u003edata;\n1141:\t\trmnet_map_v5_set_nlos(coal_hdr, num_nlos);\n1142:\t\tskb_pull(coal_skb, sizeof(*coal_hdr));\n1143:\t\n1144:\t\tif (!rmnet_map_coal_parse_ip_hdr(coal_skb, \u0026coal_meta, \u0026gro))\n1145:\t\t\treturn -EINVAL;\n1146:\t\n1147:\t\tif (!rmnet_map_coal_parse_trans_hdr(coal_skb, \u0026coal_meta))\n1148:\t\t\treturn -EINVAL;\n1149:\t\n1150:\t\thlen = coal_meta.ip_len + coal_meta.trans_len;\n1151:\t\n1152:\t\tif (!rmnet_map_coal_validate_bounds(coal_skb, coal_hdr, num_nlos, hlen,\n1153:\t\t\t\t\t\t \u0026gro)) {\n1154:\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n1155:\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_bounds_err);\n1156:\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n1157:\t\t\treturn -EINVAL;\n1158:\t\t}\n1159:\t\n1160:\t\t/* Device capability gates coalesced delivery. Packet format can still\n1161:\t\t * disable GSO and use the per-packet fallback below.\n1162:\t\t */\n1163:\t\tif (total_pkts \u003e 1 \u0026\u0026 (!rxcsum || !gro_hw))\n1164:\t\t\treturn -EINVAL;\n1165:\t\n1166:\t\tif (gro \u0026\u0026 total_pkts \u003e 1) {\n1167:\t\t\t/* Standard counters cover delivered HW-GRO skbs. coal_rx and\n1168:\t\t\t * coal_pkts cover coalescing input regardless of HW-GRO.\n1169:\t\t\t */\n1170:\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n1171:\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.rx_hw_gro_packets);\n1172:\t\t\tu64_stats_add(\u0026pcpu_ptr-\u003epriv_stats.rx_hw_gro_wire_packets, total_pkts);\n1173:\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n1174:\t\t}\n1175:\t\n1176:\t\tif (total_pkts == 1 \u0026\u0026 (!rxcsum || !gro_hw)) {\n1177:\t\t\tcoal_skb-\u003eip_summed = CHECKSUM_NONE;\n1178:\t\t\t__skb_queue_tail(list, coal_skb);\n1179:\t\t\treturn 0;\n1180:\t\t}\n1181:\t\n1182:\t\tif (rmnet_map_v5_csum_fixup(coal_hdr) \u0026\u0026 !coal_meta.zero_csum) {\n1183:\t\t\tcoal_skb-\u003eip_summed = CHECKSUM_NONE;\n1184:\t\t\t__skb_queue_tail(list, coal_skb);\n1185:\t\t\treturn 0;\n1186:\t\t}\n1187:\t\n1188:\t\tif (rmnet_map_coal_gro_fast_path(coal_skb, coal_hdr, \u0026coal_meta, list,\n1189:\t\t\t\t\t\t num_nlos, gro))\n1190:\t\t\treturn 0;\n1191:\t\n1192:\t\trmnet_map_coal_segment_loop(coal_skb, coal_hdr, \u0026coal_meta, list,\n1193:\t\t\t\t\t nlo_err_mask, gro, num_nlos);\n1194:\t\n1195:\t\treturn 0;\n1196:\t}\n1197:\t\n1198:\t/* Log the hardware close-reason counter for a coalescing header. */\n1199:\tstatic void rmnet_map_data_log_close_stats(struct rmnet_pcpu_stats *pcpu_ptr,\n"
} |
| 59/3 | 2026/10/08 01:24 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 58788 output: 50 thoughts: 17 Thoughts: Okay, here's the summary, formatted as requested: **Navigating the Digital Landscape: A Focused Examination** Alright, let's zero in. My immediate concern is a specific range, specifically lines 1200 to 1380. I need to understand what's happening within that segment. This isn't a casual scan; it's a deep dive. I'm focusing on that delimited area because, based on the preliminary indicators, I expect to find something of particular interest – a potential anomaly, a critical process, or maybe just a particularly well-crafted piece of code that deserves closer attention. My experience tells me that within this range lies a specific key or set of keys to unlock a specific challenge. Let's see what we find. |
| 60/3 | 2026/10/08 01:24 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c",
"FirstLine": 1270,
"LineCount": 90
}Results: {
"Contents": "1270:\t * hardware spills a wide NLO's error bits into the csum_error_bitmap\n1271:\t * bytes of the following slots rather than truncating them. The\n1272:\t * six bitmap bytes are therefore always concatenated in slot order\n1273:\t * into one flat RMNET_MAP_V5_MAX_NLOS * 8 = RMNET_MAP_V5_MAX_PACKETS\n1274:\t * bit value, addressed by a packet's absolute position in the frame,\n1275:\t * regardless of how many NLOs are actually in use. Receivers must\n1276:\t * walk it as a single contiguous stream and must not expect it to\n1277:\t * align it at NLO boundaries.\n1278:\t */\n1279:\tstatic int rmnet_map_data_check_coal_header(struct sk_buff *skb,\n1280:\t\t\t\t\t\t u64 *nlo_err_mask,\n1281:\t\t\t\t\t\t u8 *num_nlos,\n1282:\t\t\t\t\t\t u16 *num_pkts)\n1283:\t{\n1284:\t\tstruct rmnet_map_header *maph = (struct rmnet_map_header *)skb-\u003edata;\n1285:\t\tstruct rmnet_priv *priv = netdev_priv(skb-\u003edev);\n1286:\t\tstruct rmnet_map_v5_coal_header *coal_hdr;\n1287:\t\tstruct rmnet_pcpu_stats *pcpu_ptr;\n1288:\t\tu16 pkts = 0;\n1289:\t\tu64 mask = 0;\n1290:\t\tint nlos;\n1291:\t\tint i;\n1292:\t\n1293:\t\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\n1294:\t\n1295:\t\t/* coal header is counted in pkt_len */\n1296:\t\tif (ntohs(maph-\u003epkt_len) \u003c sizeof(*coal_hdr)) {\n1297:\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n1298:\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_hdr_err);\n1299:\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n1300:\t\t\treturn -EINVAL;\n1301:\t\t}\n1302:\t\n1303:\t\tcoal_hdr = (struct rmnet_map_v5_coal_header *)(skb-\u003edata + sizeof(*maph));\n1304:\t\tnlos = rmnet_map_v5_get_num_nlos(coal_hdr);\n1305:\t\tif (nlos \u003c 0) {\n1306:\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n1307:\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_hdr_err);\n1308:\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n1309:\t\t\treturn -EINVAL;\n1310:\t\t}\n1311:\t\n1312:\t\t*num_nlos = nlos;\n1313:\t\tfor (i = 0; i \u003c RMNET_MAP_V5_MAX_NLOS; i++) {\n1314:\t\t\tu8 err = coal_hdr-\u003enl_pairs[i].csum_error_bitmap;\n1315:\t\t\tu8 pkt = coal_hdr-\u003enl_pairs[i].num_packets;\n1316:\t\n1317:\t\t\tmask |= ((u64)err) \u003c\u003c (8 * i);\n1318:\t\t\tif (i \u003c *num_nlos) {\n1319:\t\t\t\tpkts += pkt;\n1320:\t\t\t\tif (pkts \u003e RMNET_MAP_V5_MAX_PACKETS) {\n1321:\t\t\t\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n1322:\t\t\t\t\tu64_stats_inc(\u0026pcpu_ptr-\u003epriv_stats.coal_hdr_pkt_err);\n1323:\t\t\t\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n1324:\t\t\t\t\treturn -EINVAL;\n1325:\t\t\t\t}\n1326:\t\t\t}\n1327:\t\t}\n1328:\t\n1329:\t\t/* coal_pkts counts packets reported by the hardware, independent of\n1330:\t\t * whether the frame is later delivered through HW-GRO.\n1331:\t\t */\n1332:\t\tu64_stats_update_begin(\u0026pcpu_ptr-\u003esyncp);\n1333:\t\tu64_stats_add(\u0026pcpu_ptr-\u003epriv_stats.coal_pkts, pkts);\n1334:\t\tu64_stats_update_end(\u0026pcpu_ptr-\u003esyncp);\n1335:\t\trmnet_map_data_log_close_stats(pcpu_ptr,\n1336:\t\t\t\t\t u8_get_bits(coal_hdr-\u003eclose_info,\n1337:\t\t\t\t\t\t\t MAPV5_CLOSEINFO_CLOSE_TYPE_FMASK),\n1338:\t\t\t\t\t u8_get_bits(coal_hdr-\u003eclose_info,\n1339:\t\t\t\t\t\t\t MAPV5_CLOSEINFO_CLOSE_VALUE_FMASK));\n1340:\t\n1341:\t\t*nlo_err_mask = mask;\n1342:\t\t*num_pkts = pkts;\n1343:\t\treturn 0;\n1344:\t}\n1345:\t\n1346:\tint rmnet_map_process_next_hdr_packet(struct sk_buff *skb,\n1347:\t\t\t\t\t struct sk_buff_head *list,\n1348:\t\t\t\t\t u16 len, u32 data_format)\n1349:\t{\n1350:\t\tstruct rmnet_priv *priv = netdev_priv(skb-\u003edev);\n1351:\t\tstruct rmnet_pcpu_stats *pcpu_ptr;\n1352:\t\tu64 nlo_err_mask;\n1353:\t\tu16 num_pkts;\n1354:\t\tu8 num_nlos;\n1355:\t\tint rc;\n1356:\t\n1357:\t\tpcpu_ptr = this_cpu_ptr(priv-\u003epcpu_stats);\n1358:\t\n1359:\t\tswitch (rmnet_map_get_next_hdr_type(skb)) {\n"
} |
| 61/3 | 2026/10/08 01:24 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 60708 output: 46 thoughts: 930 Thoughts: **Analyzing RMNET Packet Validation and Processing** Okay, let's dissect this `rmnet_map_validate_packet_len` function. It looks like its primary job is to verify the length of incoming packets, likely within the RMNET framework. I'm focusing on the RMNET MAP data path, so I need to understand this validation step. I see it's in `drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c`. My initial thought is to trace the execution and what happens with the function call. The core of this seems to revolve around the `skb` (socket buffer) and the `data_format`. It appears to calculate an expected packet length (`packet_len`) based on several factors, including whether checksums (v4 or v5), coalescing, and the presence of a "next header" are enabled. Crucially, I see it's using `ntohs(maph->pkt_len)` and adding `sizeof(*maph)`. Hold on... I need to make sure I grasp the subtle nuance of `RMNET_MAP_HEADER_TYPE_COALESCING` case. It seems the `pkt_len` field in the MAP header *already* includes the length of the coalescing header itself. Good, I'm getting that. That's consistent with my understanding of these types of headers. Okay, let's trace this now. If the calculated `packet_len` exceeds the actual `skb->len`, the function returns 0, indicating an invalid packet. Then, I see this is used in `rmnet_map_process_next_hdr_packet`, so I want to understand what's in that function. Specifically, `rmnet_map_data_check_coal_header`. I'm seeing it's checking the size of the packet against the coalescing header: `if (ntohs(maph->pkt_len) < sizeof(*coal_hdr))` return -EINVAL. Now, I'm getting a little concerned about potential out-of-bounds reads. I need to make sure there are adequate bounds checks on the `skb` data as headers are pulled and sliced. Let's trace it back through the calls. I see `__rmnet_map_ingress_handler` uses this function. It appears that there's a conditional branch based on the `data_format` flags and the `MAP_NEXT_HEADER_FLAG`. Where does the `len` variable come from in `__rmnet_map_ingress_handler`? It is important to know if that variable can be influenced. I need to dig further into `__rmnet_map_ingress_handler` in `rmnet_handlers.c`. |
| 62/3 | 2026/10/08 01:24 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c",
"FirstLine": 55,
"LineCount": 55
}Results: {
"Contents": " 55:\t\tstruct sk_buff *skb;\n 56:\t\n 57:\t\twhile ((skb = __skb_dequeue(head))) {\n 58:\t\t\trmnet_set_skb_proto(skb);\n 59:\t\t\trmnet_deliver_skb(skb);\n 60:\t\t}\n 61:\t}\n 62:\t\n 63:\t/* MAP handler */\n 64:\t\n 65:\tstatic void\n 66:\t__rmnet_map_ingress_handler(struct sk_buff *skb,\n 67:\t\t\t\t struct rmnet_port *port,\n 68:\t\t\t\t u32 data_format)\n 69:\t{\n 70:\t\tstruct rmnet_map_header *map_header = (void *)skb-\u003edata;\n 71:\t\tstruct rmnet_endpoint *ep;\n 72:\t\tstruct sk_buff_head list;\n 73:\t\tu16 len, pad;\n 74:\t\tu8 mux_id;\n 75:\t\n 76:\t\tif (map_header-\u003eflags \u0026 MAP_CMD_FLAG) {\n 77:\t\t\t/* Packet contains a MAP command (not data) */\n 78:\t\t\tif (data_format \u0026 RMNET_FLAGS_INGRESS_MAP_COMMANDS)\n 79:\t\t\t\treturn rmnet_map_command(skb, port, data_format);\n 80:\t\n 81:\t\t\tgoto free_skb;\n 82:\t\t}\n 83:\t\n 84:\t\tmux_id = map_header-\u003emux_id;\n 85:\t\tpad = map_header-\u003eflags \u0026 MAP_PAD_LEN_MASK;\n 86:\t\tlen = ntohs(map_header-\u003epkt_len) - pad;\n 87:\t\n 88:\t\tif (mux_id \u003e= RMNET_MAX_LOGICAL_EP)\n 89:\t\t\tgoto free_skb;\n 90:\t\n 91:\t\tep = rmnet_get_endpoint(port, mux_id);\n 92:\t\tif (!ep)\n 93:\t\t\tgoto free_skb;\n 94:\t\n 95:\t\tskb-\u003edev = ep-\u003eegress_dev;\n 96:\t\n 97:\t\t__skb_queue_head_init(\u0026list);\n 98:\t\n 99:\t\tif ((data_format \u0026\n 100:\t\t (RMNET_FLAGS_INGRESS_MAP_CKSUMV5 | RMNET_FLAGS_INGRESS_COALESCE)) \u0026\u0026\n 101:\t\t (map_header-\u003eflags \u0026 MAP_NEXT_HEADER_FLAG)) {\n 102:\t\t\tif (rmnet_map_process_next_hdr_packet(skb, \u0026list, len, data_format))\n 103:\t\t\t\tgoto free_skb;\n 104:\t\t} else {\n 105:\t\t\t/* Subtract MAP header */\n 106:\t\t\tskb_pull(skb, sizeof(*map_header));\n 107:\t\t\trmnet_set_skb_proto(skb);\n 108:\t\t\tif (data_format \u0026 RMNET_FLAGS_INGRESS_MAP_CKSUMV4 \u0026\u0026\n 109:\t\t\t !rmnet_map_checksum_downlink_packet(skb, len + pad))\n"
} |
| 63/3 | 2026/10/08 01:24 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 63116 output: 43 thoughts: 346 Thoughts: **Analyzing Potential Integer Underflow in RMNET MAP Handling** Okay, so I'm looking at this RMNET MAP code and immediately a red flag pops up. I calculate `len` as `ntohs(map_header->pkt_len) - pad`. My immediate concern is, are we properly handling the `pad` variable? The code subtracts `pad`, which is masked from the flags, from `pkt_len`, but does it check for underflow? I see that `skb_pull` is used to remove the headers, and `skb_trim` to reduce the SKB's data length to `len`. The code sets the number of non-line-of-sight segments, then `skb_pull` again, this time by the coal header size. The crucial question here is: is the `len` variable ever checked against the size of the coal header *before* these operations? The code *does* appear to have a check in `rmnet_map_data_check_coal_header` that returns `-EINVAL` if `ntohs(maph->pkt_len)` is less than the coal header size, but this doesn't directly address the underflow possibility. This means that if `pad` is a large value, it's possible that `ntohs(maph->pkt_len) - pad` underflows, resulting in an incorrect `len` value. That underflow would still make the check in `rmnet_map_data_check_coal_header` pass. Which leads to an important question: does `rmnet_rx_handler` or any of the callers validate `len`? I need to understand the data flow to see if there's any implicit or explicit validation of this `len` value. The next step is to examine the callers of `__rmnet_map_ingress_handler` to understand how they are handling this potential for integer underflow and the consequences of an invalid `len` value. I need to be sure that the data length is always consistent with the amount of data available in the SKB after header removal. This could lead to a serious security issue, so I need to be diligent. |
| 64/3 | 2026/10/08 01:25 | tool | grepper |
0mArgs:{
"Expression": "__rmnet_map_ingress_handler",
"PathPrefixes": [
"drivers/net/ethernet/qualcomm/rmnet/"
]
}Results: {
"Output": "drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c=65=static void\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c:66:__rmnet_map_ingress_handler(struct sk_buff *skb,\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c-67-\t\t\t struct rmnet_port *port,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c=123=rmnet_map_ingress_handler(struct sk_buff *skb,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c-141-\t\twhile ((skbn = rmnet_map_deaggregate(skb, data_format)) != NULL)\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c:142:\t\t\t__rmnet_map_ingress_handler(skbn, port, data_format);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c-143-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c-146-\t\tif (rmnet_map_validate_packet_len(skb, data_format))\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c:147:\t\t\t__rmnet_map_ingress_handler(skb, port, data_format);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c-148-\t\telse\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c=1047=static void rmnet_map_coal_segment_loop(struct sk_buff *coal_skb,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1115-/* Expand a coalesced SKB into individual IP packets placed on the list.\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:1116: * NLOs with checksum errors are dropped. __rmnet_map_ingress_handler will\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-1117- * free the SKB in the error case.\n"
} |
| 65/3 | 2026/10/08 01:25 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 64557 output: 47 thoughts: 36 Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience: **Diving into the RMNET Ingress Handler** Okay, time to get to the heart of the matter. I need to take a look at the ingress handler function for RMNET. Specifically, I want to examine `rmnet_map_ingress_handler` within `drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c`. This is where the magic happens, where the incoming RMNET packets are likely processed and mapped. I need to understand how the driver is handling the data flow on ingress, probably looking at packet classification, queuing, or any relevant data structure manipulation. Let's see what secrets this handler holds. |
| 66/3 | 2026/10/08 01:25 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c",
"FirstLine": 120,
"LineCount": 40
}Results: {
"Contents": " 120:\t}\n 121:\t\n 122:\tstatic void\n 123:\trmnet_map_ingress_handler(struct sk_buff *skb,\n 124:\t\t\t\t struct rmnet_port *port)\n 125:\t{\n 126:\t\tstruct sk_buff *skbn;\n 127:\t\tu32 data_format;\n 128:\t\n 129:\t\tif (skb-\u003edev-\u003etype == ARPHRD_ETHER) {\n 130:\t\t\tif (pskb_expand_head(skb, ETH_HLEN, 0, GFP_ATOMIC)) {\n 131:\t\t\t\tkfree_skb(skb);\n 132:\t\t\t\treturn;\n 133:\t\t\t}\n 134:\t\n 135:\t\t\tskb_push(skb, ETH_HLEN);\n 136:\t\t}\n 137:\t\n 138:\t\tdata_format = READ_ONCE(port-\u003edata_format);\n 139:\t\n 140:\t\tif (data_format \u0026 RMNET_FLAGS_INGRESS_DEAGGREGATION) {\n 141:\t\t\twhile ((skbn = rmnet_map_deaggregate(skb, data_format)) != NULL)\n 142:\t\t\t\t__rmnet_map_ingress_handler(skbn, port, data_format);\n 143:\t\n 144:\t\t\tconsume_skb(skb);\n 145:\t\t} else {\n 146:\t\t\tif (rmnet_map_validate_packet_len(skb, data_format))\n 147:\t\t\t\t__rmnet_map_ingress_handler(skb, port, data_format);\n 148:\t\t\telse\n 149:\t\t\t\tkfree_skb(skb);\n 150:\t\t}\n 151:\t}\n 152:\t\n 153:\tstatic int rmnet_map_egress_handler(struct sk_buff *skb,\n 154:\t\t\t\t\t struct rmnet_port *port, u8 mux_id,\n 155:\t\t\t\t\t struct net_device *orig_dev)\n 156:\t{\n 157:\t\tint required_headroom, additional_header_len, csum_type = 0;\n 158:\t\tstruct rmnet_map_header *map_header;\n 159:\t\tu32 data_format;\n"
} |
| 67/3 | 2026/10/08 01:25 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 65425 output: 41 thoughts: 17 Thoughts: Okay, let's dive into this `rmnet_map_deaggregate` function. I'm always looking for ways to optimize these processes, so understanding the ins and outs of this function is key. I need to figure out what it's specifically designed to *do*. What's its role in the bigger picture? Is it handling packet fragmentation, or perhaps some specific RMNET protocol aggregation? The naming convention is a good starting point, but I need to see the implementation to truly understand its mechanics. I'm curious about the specific algorithms used, potential performance bottlenecks, and if there are any opportunities for improvement. I'll need to analyze the surrounding code to grasp its context within the RMNET framework. My focus will be on the core logic and error handling to ensure efficiency and reliability. Let's see what we can find. |
| 68/3 | 2026/10/08 01:25 | tool | grepper |
0mArgs:{
"Expression": "rmnet_map_deaggregate",
"PathPrefixes": [
"drivers/net/ethernet/qualcomm/rmnet/"
]
}Results: {
"Output": "drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c=123=rmnet_map_ingress_handler(struct sk_buff *skb,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c-140-\tif (data_format \u0026 RMNET_FLAGS_INGRESS_DEAGGREGATION) {\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c:141:\t\twhile ((skbn = rmnet_map_deaggregate(skb, data_format)) != NULL)\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c-142-\t\t\t__rmnet_map_ingress_handler(skbn, port, data_format);\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map.h=42=enum rmnet_map_commands {\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map.h-58-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map.h:59:struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb,\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map.h-60-\t\t\t\t u32 data_format);\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c=386=u32 rmnet_map_validate_packet_len(struct sk_buff *skb, u32 data_format)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-436- */\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:437:struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb,\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c-438-\t\t\t\t u32 data_format)\n"
} |
| 69/3 | 2026/10/08 01:25 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 66163 output: 49 thoughts: 24 Thoughts: Okay, let's dive into this. Here's my take on those thoughts, as if they're my own: **Analyzing `rmnet_map_deaggregate` in `rmnet_map_data.c`** Alright, time to get my hands dirty. My instinct is telling me we need to dissect the `rmnet_map_deaggregate` function, specifically within the `rmnet_map_data.c` file. I'm already visualizing the likely challenges: deaggregation is usually where you encounter the messy details. I suspect we're likely dealing with fragmented data here, which means we have to reassemble packets, handle potential header mismatches, and probably manage some sort of buffering. I expect there might be some intricate pointer arithmetic or memory management tricks in there. Let's see if my suspicions are correct. This will require careful attention to detail, but this is a critical function, so there is no time to waste. I am ready. Let's start. |
| 70/3 | 2026/10/08 01:25 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c",
"FirstLine": 430,
"LineCount": 40
}Results: {
"Contents": " 430:\t\n 431:\t/* Deaggregates a single packet\n 432:\t * A whole new buffer is allocated for each portion of an aggregated frame.\n 433:\t * Caller should keep calling deaggregate() on the source skb until 0 is\n 434:\t * returned, indicating that there are no more packets to deaggregate. Caller\n 435:\t * is responsible for freeing the original skb.\n 436:\t */\n 437:\tstruct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb,\n 438:\t\t\t\t\t u32 data_format)\n 439:\t{\n 440:\t\tstruct sk_buff *skbn;\n 441:\t\tu32 packet_len;\n 442:\t\n 443:\t\tpacket_len = rmnet_map_validate_packet_len(skb, data_format);\n 444:\t\tif (!packet_len)\n 445:\t\t\treturn NULL;\n 446:\t\n 447:\t\tskbn = alloc_skb(packet_len + RMNET_MAP_DEAGGR_SPACING, GFP_ATOMIC);\n 448:\t\tif (!skbn)\n 449:\t\t\treturn NULL;\n 450:\t\n 451:\t\tskbn-\u003edev = skb-\u003edev;\n 452:\t\tskb_reserve(skbn, RMNET_MAP_DEAGGR_HEADROOM);\n 453:\t\tskb_put(skbn, packet_len);\n 454:\t\tmemcpy(skbn-\u003edata, skb-\u003edata, packet_len);\n 455:\t\tskb_pull(skb, packet_len);\n 456:\t\n 457:\t\treturn skbn;\n 458:\t}\n 459:\t\n 460:\t/* Validates packet checksums. Function takes a pointer to\n 461:\t * the beginning of a buffer which contains the IP payload +\n 462:\t * padding + checksum trailer.\n 463:\t * Only IPv4 and IPv6 are supported along with TCP \u0026 UDP.\n 464:\t * Fragmented or tunneled packets are not supported.\n 465:\t */\n 466:\tint rmnet_map_checksum_downlink_packet(struct sk_buff *skb, u16 len)\n 467:\t{\n 468:\t\tstruct rmnet_priv *priv = netdev_priv(skb-\u003edev);\n 469:\t\tstruct rmnet_map_dl_csum_trailer *csum_trailer;\n"
} |
| 71/3 | 2026/10/08 01:25 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 67113 output: 40 thoughts: 1784 Thoughts: **Analyzing RMNET Deaggregation and Checksum Calculation** Alright, let's dive into this `__rmnet_map_segment_coal_skb` function. The goal here seems to be reassembling and potentially checksumming fragmented packets. First, I'm noting the allocation and initialization of `skbn`, the reassembled SKB. I see a `skb_reserve` call, followed by `skb_put_data` copying `dlen` bytes. Then, the transport and IP headers are "pushed" back onto the SKB via `skb_push` and `memcpy`. This builds the full packet in `skbn`, and from the code flow, every byte is initialized. Good. This is standard SKB manipulation, making sure that everything is correct. Now, the interesting part: checksum calculation. The `rmnet_map_partial_csum` function calculates a partial checksum and sets `skb->ip_summed` to `CHECKSUM_PARTIAL`. The pseudo-header calculation looks standard, depending on whether it is IPv4 or IPv6. The code then updates the TCP or UDP checksum field. The important thing is that all fields accessed for the checksum calculation in `rmnet_map_partial_csum` *are* initialized in `skbn`, which is built above. That's a critical point to ensure correctness. I'm checking if there is any potential for uninitialized memory or out-of-bounds reads. I need to be *absolutely* certain that `skb_put_data` and the `memcpy` calls don't read beyond `coal_skb->len`. If this were happening, KASAN (Kernel Address Sanitizer) *should* detect any out-of-bounds reads. The same applies for any reads beyond the skb buffer. I'm assuming that `coal_skb` is a network SKB received from a network interface, so I'd expect it to be properly initialized. But, I need to confirm: What if the SKB is non-linear (fragmented)? Does `rmnet` handle SKBs with fragments? I need to trace back where `coal_skb` comes from, probably `rmnet_rx_handler` or some similar function, to understand whether fragmented SKBs are correctly handled within the RMNET framework. That's the key now. That's where I need to focus my attention. It could be an issue if there are any subtle interactions with SKB fragments that aren't accounted for here. I'm now going to go hunting in `rmnet_rx_handler` to find the answer. |
| 72/3 | 2026/10/08 01:26 | tool | grepper |
0mArgs:{
"Expression": "rmnet_rx_handler",
"PathPrefixes": [
"drivers/net/ethernet/qualcomm/rmnet/"
]
}Results: {
"Output": "drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=24=static int rmnet_is_real_dev_registered(const struct net_device *real_dev)\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-25-{\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:26:\treturn rcu_access_pointer(real_dev-\u003erx_handler) == rmnet_rx_handler;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-27-}\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=78=static int rmnet_register_real_device(struct net_device *real_dev,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-100-\tport-\u003edev = real_dev;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:101:\trc = netdev_rx_handler_register(real_dev, rmnet_rx_handler, port);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-102-\tif (rc) {\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c=205=rmnet_bridge_handler(struct sk_buff *skb, struct net_device *bridge_dev)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c-221- */\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c:222:rx_handler_result_t rmnet_rx_handler(struct sk_buff **pskb)\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c-223-{\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.h=12=void rmnet_egress_handler(struct sk_buff *skb);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.h-13-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.h:14:rx_handler_result_t rmnet_rx_handler(struct sk_buff **pskb);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.h-15-\n"
} |
| 73/3 | 2026/10/08 01:26 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 70102 output: 47 thoughts: 21 Thoughts: Okay, let's dive in. Here's my thought process regarding the provided prompt, summarized in the first person: **Analyzing the rmnet_rx_handler** Right, let's take a look. The prompt indicates we need to examine `rmnet_rx_handler`, and it's specified as being located in `rmnet_handlers.c`. Okay, that's straightforward. This is probably where the data reception path for the RMNET interface is managed. Given the name, it's highly probable this is the core function handling incoming packets from the RMNET interface. I need to understand what this function does: How it interacts with the lower layers, how it processes the received data, and how it delivers that data to higher-level protocols or applications. I'll need to pay close attention to the data structures involved, any potential locking mechanisms, and error handling within this handler. Specifically, I need to understand the data flow, the decisions being made on the packets, and how the packets are handled. Time to dig in and understand this critical piece of the RMNET puzzle. |
| 74/3 | 2026/10/08 01:26 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c",
"FirstLine": 220,
"LineCount": 40
}Results: {
"Contents": " 220:\t * egress device listed in the logical endpoint configuration.\n 221:\t */\n 222:\trx_handler_result_t rmnet_rx_handler(struct sk_buff **pskb)\n 223:\t{\n 224:\t\tstruct sk_buff *skb = *pskb;\n 225:\t\tstruct rmnet_port *port;\n 226:\t\tstruct net_device *dev;\n 227:\t\n 228:\t\tif (!skb)\n 229:\t\t\tgoto done;\n 230:\t\n 231:\t\tif (skb_linearize(skb)) {\n 232:\t\t\tkfree_skb(skb);\n 233:\t\t\tgoto done;\n 234:\t\t}\n 235:\t\n 236:\t\tif (skb-\u003epkt_type == PACKET_LOOPBACK)\n 237:\t\t\treturn RX_HANDLER_PASS;\n 238:\t\n 239:\t\tdev = skb-\u003edev;\n 240:\t\tport = rmnet_get_port_rcu(dev);\n 241:\t\tif (unlikely(!port)) {\n 242:\t\t\tdev_core_stats_rx_nohandler_inc(skb-\u003edev);\n 243:\t\t\tkfree_skb(skb);\n 244:\t\t\tgoto done;\n 245:\t\t}\n 246:\t\n 247:\t\tswitch (port-\u003ermnet_mode) {\n 248:\t\tcase RMNET_EPMODE_VND:\n 249:\t\t\trmnet_map_ingress_handler(skb, port);\n 250:\t\t\tbreak;\n 251:\t\tcase RMNET_EPMODE_BRIDGE:\n 252:\t\t\trmnet_bridge_handler(skb, port-\u003ebridge_ep);\n 253:\t\t\tbreak;\n 254:\t\t}\n 255:\t\n 256:\tdone:\n 257:\t\treturn RX_HANDLER_CONSUMED;\n 258:\t}\n 259:\t\n"
} |
| 75/3 | 2026/10/08 01:26 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 70944 output: 32 thoughts: 1575 Thoughts: **Analyzing the RMNET Coal Segmentation Path** Okay, let's break down this RMNET coal segmentation process. The code starts with `skb_linearize(skb)` right away, which is my starting point for ensuring contiguous data. I'm going to track data initialization and copies as this is critical for understanding the memory and lifecycle management of these `sk_buff` structures. First, let's examine `rmnet_map_data_check_coal_header`. Here, `nlo_err_mask`, `num_nlos`, and `num_pkts` are potential out parameters. It's important that they are handled correctly. The code initializes local variables `pkts`, `mask` and `nlos`, and `pcpu_ptr`. Crucially, if the function returns an error (which I note is `-EINVAL`), these out parameters are *not* written to. The caller checks the return code immediately, and returns if an error occurs. I note that this prevents the use of uninitialized values. On success, they *are* initialized, making the code's data flow consistent. Next, I'll move on to `rmnet_map_coal_parse_ip_hdr`. This function takes a `coal_skb` and a `meta` structure as inputs, along with a `gro` pointer. The caller *always* initializes `coal_meta` with `memset`, ensuring a known starting state. The function returns a boolean. If it returns false, it returns `-EINVAL`. If it returns true, `meta->ip_proto`, `meta->ip_len`, `meta->trans_proto`, and `meta->ip_header` are filled in. Good. Consistent error handling and predictable output. `rmnet_map_coal_parse_trans_hdr` also has a similar pattern. Return false means `-EINVAL` is returned, and true results in the setting of `meta->trans_len` and `meta->trans_header`. It also sets `meta->zero_csum` under certain conditions. Now, `rmnet_map_coal_validate_bounds` is a sanity check. It validates lengths and packet bounds. Critical, as bounds checks prevent buffer overflows. Then, we have a fast path: `rmnet_map_coal_gro_fast_path`. If it returns true, it enqueues the `coal_skb` after calling `rmnet_map_partial_csum` and `rmnet_map_gso_stamp`. These are important for checksums and Generic Segmentation Offload (GSO). If false, it falls back to a loop. The loop itself is `rmnet_map_coal_segment_loop`. This iterates through NLOs and calls `__rmnet_map_segment_coal_skb`, which, from the name, performs the actual segmentation. Now, let's follow the control flow in `rmnet_map_process_next_hdr_packet`. This is a critical point. `rmnet_map_segment_coal_skb` is called, and if it succeeds, the code checks `skb_peek(list) != skb`. This is where the segmentation result is acted upon. If the condition is true it means either the fast-path didn't happen, or the original `skb` is not the first on the list. If `list` is empty, indicating an error causing all segments to be dropped, then the original `skb` is freed. Otherwise the original `skb` has been consumed, because new segments are enqueued and need to be processed. If the fast path was taken or `total_pkts == 1`, then the `skb` is already on the list, so it is *not* freed, because it is the new packet. This looks like efficient memory management to me, and correct logic. Finally, in `__rmnet_map_ingress_handler`, `rmnet_deliver_skb_list(&list)` is called. This dequeues each SKB, calls `rmnet_set_skb_proto` and `rmnet_deliver_skb`. This is where the packets are ultimately delivered. And oh, hold on, I need to check something... I need to see how queue statistics work. Let's see: `rmnet_get_queue_stats_rx`... is it related to netlink stats requests? I will investigate how `stat_ops` is used in the kernel. This is critical for monitoring the RMNET's performance. Okay, I'll search for where `get_queue_stats_rx` is called. |
| 76/3 | 2026/10/08 01:26 | tool | grepper |
0mArgs:{
"Expression": "get_queue_stats_rx",
"PathPrefixes": [
"net/core/"
]
}Results: {
"Output": "net/core/netdev-genl.c=724=netdev_nl_stats_queue(struct net_device *netdev, struct sk_buff *rsp,\n--\nnet/core/netdev-genl.c-742-\t\tmemset(\u0026rx, 0xff, sizeof(rx));\nnet/core/netdev-genl.c:743:\t\tops-\u003eget_queue_stats_rx(netdev, i, \u0026rx);\nnet/core/netdev-genl.c-744-\t\tif (!memchr_inv(\u0026rx, 0xff, sizeof(rx)))\n--\nnet/core/netdev-genl.c=771=netdev_nl_stats_by_queue(struct net_device *netdev, struct sk_buff *rsp,\n--\nnet/core/netdev-genl.c-781-\ti = ctx-\u003erxq_idx;\nnet/core/netdev-genl.c:782:\twhile (ops-\u003eget_queue_stats_rx \u0026\u0026 i \u003c netdev-\u003ereal_num_rx_queues) {\nnet/core/netdev-genl.c-783-\t\terr = netdev_nl_stats_queue(netdev, rsp, NETDEV_QUEUE_TYPE_RX,\n--\nnet/core/netdev-genl.c=817=void netdev_stat_queue_sum(struct net_device *netdev,\n--\nnet/core/netdev-genl.c-831-\t\tmemset(\u0026rx, 0xff, sizeof(rx));\nnet/core/netdev-genl.c:832:\t\tif (ops-\u003eget_queue_stats_rx)\nnet/core/netdev-genl.c:833:\t\t\tops-\u003eget_queue_stats_rx(netdev, i, \u0026rx);\nnet/core/netdev-genl.c-834-\t\tnetdev_nl_stats_add(rx_sum, \u0026rx, sizeof(rx));\n"
} |
| 77/3 | 2026/10/08 01:26 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 74051 output: 39 thoughts: 123 Thoughts: **Investigating Potential Data Corruption in Network Device Statistics** Okay, so I'm looking into some potentially odd behavior with network device statistics, and I've zeroed in on `net/core/netdev-genl.c`. Specifically, I'm examining this snippet: `memset(&rx, 0xff, sizeof(rx)); ops->get_queue_stats_rx(netdev, i, &rx);`. Wait a second... `memset(&rx, 0xff, sizeof(rx))`? That immediately jumped out at me. Why are they initializing with all bits set to 1? That seems like a really unusual, and potentially dangerous, initialization strategy for a structure that's going to hold statistics. My mind races. I need to understand this better. I need to see what's happening downstream. I'll read around lines 740-770 in `net/core/netdev-genl.c`, focusing on the functions `netdev_nl_stats_queue` and `netdev_nl_stats_add`. This is the crux of how the data is handled after the statistics are retrieved. I need to understand how the `0xff` initialization affects the data being passed in, and ultimately, whether this is leading to potential data corruption or unexpected values in the reported statistics. I suspect that this *could* be a bug. Let's see... |
| 78/3 | 2026/10/08 01:26 | tool | read-file |
0mArgs:{
"File": "net/core/netdev-genl.c",
"FirstLine": 724,
"LineCount": 45
}Results: {
"Contents": " 724:\tnetdev_nl_stats_queue(struct net_device *netdev, struct sk_buff *rsp,\n 725:\t\t\t u32 q_type, int i, const struct genl_info *info)\n 726:\t{\n 727:\t\tconst struct netdev_stat_ops *ops = netdev-\u003estat_ops;\n 728:\t\tstruct netdev_queue_stats_rx rx;\n 729:\t\tstruct netdev_queue_stats_tx tx;\n 730:\t\tvoid *hdr;\n 731:\t\n 732:\t\thdr = genlmsg_iput(rsp, info);\n 733:\t\tif (!hdr)\n 734:\t\t\treturn -EMSGSIZE;\n 735:\t\tif (nla_put_u32(rsp, NETDEV_A_QSTATS_IFINDEX, netdev-\u003eifindex) ||\n 736:\t\t nla_put_u32(rsp, NETDEV_A_QSTATS_QUEUE_TYPE, q_type) ||\n 737:\t\t nla_put_u32(rsp, NETDEV_A_QSTATS_QUEUE_ID, i))\n 738:\t\t\tgoto nla_put_failure;\n 739:\t\n 740:\t\tswitch (q_type) {\n 741:\t\tcase NETDEV_QUEUE_TYPE_RX:\n 742:\t\t\tmemset(\u0026rx, 0xff, sizeof(rx));\n 743:\t\t\tops-\u003eget_queue_stats_rx(netdev, i, \u0026rx);\n 744:\t\t\tif (!memchr_inv(\u0026rx, 0xff, sizeof(rx)))\n 745:\t\t\t\tgoto nla_cancel;\n 746:\t\t\tif (netdev_nl_stats_write_rx(rsp, \u0026rx))\n 747:\t\t\t\tgoto nla_put_failure;\n 748:\t\t\tbreak;\n 749:\t\tcase NETDEV_QUEUE_TYPE_TX:\n 750:\t\t\tmemset(\u0026tx, 0xff, sizeof(tx));\n 751:\t\t\tops-\u003eget_queue_stats_tx(netdev, i, \u0026tx);\n 752:\t\t\tif (!memchr_inv(\u0026tx, 0xff, sizeof(tx)))\n 753:\t\t\t\tgoto nla_cancel;\n 754:\t\t\tif (netdev_nl_stats_write_tx(rsp, \u0026tx))\n 755:\t\t\t\tgoto nla_put_failure;\n 756:\t\t\tbreak;\n 757:\t\t}\n 758:\t\n 759:\t\tgenlmsg_end(rsp, hdr);\n 760:\t\treturn 0;\n 761:\t\n 762:\tnla_cancel:\n 763:\t\tgenlmsg_cancel(rsp, hdr);\n 764:\t\treturn 0;\n 765:\tnla_put_failure:\n 766:\t\tgenlmsg_cancel(rsp, hdr);\n 767:\t\treturn -EMSGSIZE;\n 768:\t}\n"
} |
| 79/3 | 2026/10/08 01:26 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 75294 output: 35 thoughts: 71 Thoughts: Here's my summary, as I understand the situation: **Decoding the Initialization Logic** Okay, so the caller's initializing `rx` to `0xff`, which is effectively all bits set, and that initially threw me a bit. Then, I realized why: it's tied to how they are handling unset fields in `netdev_queue_stats_rx`. Using `~0ULL` (bitwise NOT of an unsigned long long, or all bits set) as the "unset" indicator makes perfect sense in this context. The code within `netdev_nl_stats_write_rx` will be checking each individual field against that `~0ULL` value. If a field *isn't* equal to `~0ULL`, it means the statistic has a valid, non-default value that needs to be written. This allows for a clean separation between actually reported data and uninitialized values. Now, I need to double-check that this expectation holds true within `netdev_nl_stats_write_rx` itself. I need to fully understand its logic. |
| 80/3 | 2026/10/08 01:26 | tool | grepper |
0mArgs:{
"Expression": "netdev_nl_stats_write_rx",
"PathPrefixes": [
"net/core/"
]
}Results: {
"Output": "net/core/netdev-genl.c=682=static int\nnet/core/netdev-genl.c:683:netdev_nl_stats_write_rx(struct sk_buff *rsp, struct netdev_queue_stats_rx *rx)\nnet/core/netdev-genl.c-684-{\n--\nnet/core/netdev-genl.c=724=netdev_nl_stats_queue(struct net_device *netdev, struct sk_buff *rsp,\n--\nnet/core/netdev-genl.c-745-\t\t\tgoto nla_cancel;\nnet/core/netdev-genl.c:746:\t\tif (netdev_nl_stats_write_rx(rsp, \u0026rx))\nnet/core/netdev-genl.c-747-\t\t\tgoto nla_put_failure;\n--\nnet/core/netdev-genl.c=846=netdev_nl_stats_by_netdev(struct net_device *netdev, struct sk_buff *rsp,\n--\nnet/core/netdev-genl.c-875-\nnet/core/netdev-genl.c:876:\tif (netdev_nl_stats_write_rx(rsp, \u0026rx_sum) ||\nnet/core/netdev-genl.c-877-\t netdev_nl_stats_write_tx(rsp, \u0026tx_sum))\n"
} |
| 81/3 | 2026/10/08 01:26 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 75994 output: 39 thoughts: 16 Thoughts: Okay, let's dive into this. Here's my thought process on dissecting `netdev_nl_stats_write_rx`, as an expert: **Analyzing `netdev_nl_stats_write_rx`** Alright, so the task at hand is `netdev_nl_stats_write_rx`. Immediately, the "netdev" prefix screams "network device," which is pretty obvious. The "nl" implies "netlink," suggesting this function is interacting with the kernel's netlink interface for network device statistics. The suffix "rx" means this function specifically handles receiving, or inbound, data. Given my experience, I'm expecting this function to be a key piece in processing network interface statistics updates that are coming from userspace via netlink, very likely related to counters like bytes received, packets received, errors, etc., the stuff the `ifconfig` output is ultimately built on. I will look for functions to process the netlink message data and potentially update per-device statistics structures within the kernel. I also expect this function to involve some locking, since multiple processes can call netlink and concurrently try to update counters. |
| 82/3 | 2026/10/08 01:27 | tool | read-file |
0mArgs:{
"File": "net/core/netdev-genl.c",
"FirstLine": 682,
"LineCount": 40
}Results: {
"Contents": " 682:\tstatic int\n 683:\tnetdev_nl_stats_write_rx(struct sk_buff *rsp, struct netdev_queue_stats_rx *rx)\n 684:\t{\n 685:\t\tif (netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_PACKETS, rx-\u003epackets) ||\n 686:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_BYTES, rx-\u003ebytes) ||\n 687:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_ALLOC_FAIL, rx-\u003ealloc_fail) ||\n 688:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_HW_DROPS, rx-\u003ehw_drops) ||\n 689:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_HW_DROP_OVERRUNS, rx-\u003ehw_drop_overruns) ||\n 690:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_CSUM_COMPLETE, rx-\u003ecsum_complete) ||\n 691:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_CSUM_UNNECESSARY, rx-\u003ecsum_unnecessary) ||\n 692:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_CSUM_NONE, rx-\u003ecsum_none) ||\n 693:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_CSUM_BAD, rx-\u003ecsum_bad) ||\n 694:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_HW_GRO_PACKETS, rx-\u003ehw_gro_packets) ||\n 695:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_HW_GRO_BYTES, rx-\u003ehw_gro_bytes) ||\n 696:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_HW_GRO_WIRE_PACKETS, rx-\u003ehw_gro_wire_packets) ||\n 697:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_HW_GRO_WIRE_BYTES, rx-\u003ehw_gro_wire_bytes) ||\n 698:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_HW_DROP_RATELIMITS, rx-\u003ehw_drop_ratelimits))\n 699:\t\t\treturn -EMSGSIZE;\n 700:\t\treturn 0;\n 701:\t}\n 702:\t\n 703:\tstatic int\n 704:\tnetdev_nl_stats_write_tx(struct sk_buff *rsp, struct netdev_queue_stats_tx *tx)\n 705:\t{\n 706:\t\tif (netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_PACKETS, tx-\u003epackets) ||\n 707:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_BYTES, tx-\u003ebytes) ||\n 708:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_HW_DROPS, tx-\u003ehw_drops) ||\n 709:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_HW_DROP_ERRORS, tx-\u003ehw_drop_errors) ||\n 710:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_CSUM_NONE, tx-\u003ecsum_none) ||\n 711:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_NEEDS_CSUM, tx-\u003eneeds_csum) ||\n 712:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_HW_GSO_PACKETS, tx-\u003ehw_gso_packets) ||\n 713:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_HW_GSO_BYTES, tx-\u003ehw_gso_bytes) ||\n 714:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_HW_GSO_WIRE_PACKETS, tx-\u003ehw_gso_wire_packets) ||\n 715:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_HW_GSO_WIRE_BYTES, tx-\u003ehw_gso_wire_bytes) ||\n 716:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_HW_DROP_RATELIMITS, tx-\u003ehw_drop_ratelimits) ||\n 717:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_STOP, tx-\u003estop) ||\n 718:\t\t netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_WAKE, tx-\u003ewake))\n 719:\t\t\treturn -EMSGSIZE;\n 720:\t\treturn 0;\n 721:\t}\n"
} |
| 83/3 | 2026/10/08 01:27 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 77597 output: 42 thoughts: 329 Thoughts: **Analyzing the Ethtool Statistics Gathering in the RMNET Driver**
Okay, so I'm looking at how the RMNET driver handles ethtool statistics. The `netdev_stat_put` function skips any attributes with a value of `~0ULL`, which is good. Also, it looks like the `rx` variable is initialized to `0xff` before calling `ops->get_queue_stats_rx`, so we're safe from leaking any uninitialized data. That's a solid start.
Now, let's dive into `rmnet_get_ethtool_stats`. The function takes the `net_device`, a `ethtool_stats` struct, and a `u64 *data` buffer as arguments. First, we have a `rmnet_priv_stats` struct called `total_stats`, which is initialized with `{ }`. This will aggregate stats from all CPUs. The code iterates through each possible CPU, collecting the statistics. Then, the `data` buffer is populated using `memcpy`, starting from `total_stats.csum_ok`. The copy covers the size of the whole struct, excluding the offset of that first attribute.
Hold on a second... This makes me pause. The important question is, how many statistics does ethtool allocate in that `data` buffer? I need to know the size of the buffer that ethtool provides to `rmnet_get_ethtool_stats`. I need to confirm that `memcpy` doesn't write out of bounds. I need to check the function that provides the statistics count. Let's see... I'll check `rmnet_get_sset_count` in `rmnet_vnd.c`. That should tell me how many statistics are reported and give me the allocation information.
|
| 84/3 | 2026/10/08 01:27 | tool | grepper |
0mArgs:{
"Expression": "rmnet_get_sset_count",
"PathPrefixes": [
"drivers/net/ethernet/qualcomm/rmnet/"
]
}Results: {
"Output": "drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c=266=static void rmnet_get_strings(struct net_device *dev, u32 stringset, u8 *buf)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-275-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:276:static int rmnet_get_sset_count(struct net_device *dev, int sset)\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-277-{\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c=397=static const struct ethtool_ops rmnet_ethtool_ops = {\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-402-\t.get_strings = rmnet_get_strings,\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:403:\t.get_sset_count = rmnet_get_sset_count,\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c-404-};\n"
} |
| 85/3 | 2026/10/08 01:27 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 78666 output: 47 thoughts: 23 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Analyzing `rmnet_get_sset_count` in `rmnet_vnd.c`** Alright, let's dive into `rmnet_get_sset_count` within `rmnet_vnd.c`. This is where the rubber meets the road, as we're likely dealing with some core functionality related to Session Set (SSET) management for RMNET, probably within a particular vendor implementation. I need to understand how the system keeps track of, and retrieves, the number of active SSETs. This will provide insight into how RMNET is handling concurrent data sessions, and what resources are being allocated. Specifically, I'm thinking about the implications for congestion control, QoS, and potentially the limitations of the hardware in managing multiple sessions concurrently. My primary interest is in looking at the potential for scalability or if there might be bottlenecks in the underlying implementation. I want to see if they've implemented any clever optimizations, such as using atomic operations, bitmasks, or pre-allocation of SSET entries. Let's see if this function's logic provides any hints about the underlying data structures used for the SSET pool. I'm also curious to see if there's any cleverness in the locking mechanisms employed to ensure thread safety when accessing and updating this count – spinlocks, mutexes, or something more sophisticated perhaps? The key here is to determine whether it’s a simple counter, or something more complex with state transitions. |
| 86/3 | 2026/10/08 01:27 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c",
"FirstLine": 270,
"LineCount": 20
}Results: {
"Contents": " 270:\t\t\tmemcpy(buf, \u0026rmnet_gstrings_stats,\n 271:\t\t\t sizeof(rmnet_gstrings_stats));\n 272:\t\t\tbreak;\n 273:\t\t}\n 274:\t}\n 275:\t\n 276:\tstatic int rmnet_get_sset_count(struct net_device *dev, int sset)\n 277:\t{\n 278:\t\tswitch (sset) {\n 279:\t\tcase ETH_SS_STATS:\n 280:\t\t\treturn ARRAY_SIZE(rmnet_gstrings_stats);\n 281:\t\tdefault:\n 282:\t\t\treturn -EOPNOTSUPP;\n 283:\t\t}\n 284:\t}\n 285:\t\n 286:\tstatic void rmnet_get_ethtool_stats(struct net_device *dev,\n 287:\t\t\t\t\t struct ethtool_stats *stats, u64 *data)\n 288:\t{\n 289:\t\tstruct rmnet_priv *priv = netdev_priv(dev);\n"
} |
| 87/3 | 2026/10/08 01:27 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 79349 output: 38 thoughts: 2904 Thoughts: **Deep Dive into RMNET Data Structures and Packet Processing** Okay, let's break this down systematically. My immediate concern is ensuring no uninitialized memory gets exposed, particularly during packet reconstruction. The initial code snippets regarding `rmnet_get_sset_count` and the static assertions are reassuring: they establish a clear and consistent relationship between the size of the statistics array and the fields being copied, suggesting good initialization practices. The use of `offsetof` further solidifies this, guaranteeing that only the relevant data is copied. The use of zero-initialization for both `total_priv_stats` and `total_stats` in `rmnet_get_stats64` is excellent. Furthermore, the standard `struct rtnl_link_stats64 *s` being provided by `dev_get_stats()` should be properly set up from the beginning. Now, the coalescing logic. Here's where it gets interesting and demands careful scrutiny. `__rmnet_map_segment_coal_skb` allocates a new `skb` in the non-fast path. However, the critical question is what is being copied into the new skb. The code copies data, restores transport and IP headers, potentially recalculates checksums based on `coal_meta` information, and restores the IP header. The TCP and UDP header manipulation seem correct: they adjust the sequence number and handle specific flags, and set the length in case of UDP. There's good reason for stripping dangerous flags from non-final TCP segments. The `ip_fast_csum` calls seem correct. IPv6 also seems right. All the relevant length fields in `ip_hdr` and `ipv6_hdr` look correct, ensuring that the packet size is correct. Then, the important function `rmnet_map_partial_csum` is called. The fast path is where the concern arises: in `rmnet_map_coal_gro_fast_path`, the original `coal_skb` is *reused* directly, provided the various conditions are met. This is a potential performance optimization, but could introduce an issue if any prior data is left uninitialized. However, the code then performs careful setup of various meta information and checksum. Looking closely, the code sets `coal_skb->ip_summed = CHECKSUM_UNNECESSARY`, which tells the stack not to verify the checksum, which seems like the right thing to do since this is part of the coalescing path. The data being processed starts at `coal_skb->data`, after `skb_pull` removes header information. Now, in `rmnet_map_process_next_hdr_packet`, if `skb_peek(list) == skb`, neither `kfree_skb` nor `consume_skb` is called, and `skb` is delivered to the stack, making the fast path important. I see no issues with the fast path, as long as the previous checks are done correctly. Now, let's consider a couple of other crucial conditions. If `total_pkts == 1 && (!rxcsum || !gro_hw)` or if `rmnet_map_v5_csum_fixup(coal_hdr)` is true, the `coal_skb` will be put directly into the list, in a way similar to fast path. In both these cases, `coal_skb->ip_summed` is set to `CHECKSUM_NONE`. This seems safe, although I'll want to trace this path with some focused fuzzing. The use of `skb_unclone` before modifying the skb in `rmnet_map_process_next_hdr_packet` is a crucial safeguard, ensuring that we're working on a unique copy and not accidentally corrupting shared data. Finally, the Netlink handling changes related to `rmnet_newlink` and `rmnet_changelink` are well-structured, validating the `IFLA_RMNET_FLAGS` data via a netlink policy check. This protects against the injection of arbitrary data formats. Looking at the logic and the checks, I feel safe about the changes. Overall, the code appears well-written and considers the necessary conditions. However, the reuse of the `coal_skb` in the fast path and those specific conditional paths warrant very close attention during testing. Fuzzing and rigorous testing are essential to prove the code robust. |
| 88/3 | 2026/10/08 01:27 | tool | grepper |
0mArgs:{
"Expression": "rmnet_policy",
"PathPrefixes": [
"drivers/net/ethernet/qualcomm/rmnet/"
]
}Results: {
"Output": "drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-18-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:19:static const struct nla_policy rmnet_policy[IFLA_RMNET_MAX + 1] = {\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-20-\t[IFLA_RMNET_MUX_ID]\t= { .type = NLA_U16 },\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=448=struct rtnl_link_ops rmnet_link_ops __read_mostly = {\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-457-\t.changelink = rmnet_changelink,\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:458:\t.policy\t\t= rmnet_policy,\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-459-\t.fill_info\t= rmnet_fill_info,\n"
} |
| 89/3 | 2026/10/08 01:27 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 83528 output: 46 thoughts: 20 Thoughts: Here's my take on those thoughts: **Investigating the `rmnet_policy` Definition** Okay, so I need to understand how `rmnet_policy` is defined. My first instinct is to dive into the source code, specifically `rmnet_config.c`. That's where I'd expect to find the actual structure or enumeration that defines it. This is a crucial first step; I need to know what data structures and values are associated with `rmnet_policy` before I can truly grasp its role and implications within the system. Let's see what we can find. |
| 90/3 | 2026/10/08 01:27 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c",
"FirstLine": 18,
"LineCount": 10
}Results: {
"Contents": " 18:\t\n 19:\tstatic const struct nla_policy rmnet_policy[IFLA_RMNET_MAX + 1] = {\n 20:\t\t[IFLA_RMNET_MUX_ID]\t= { .type = NLA_U16 },\n 21:\t\t[IFLA_RMNET_FLAGS]\t= { .len = sizeof(struct ifla_rmnet_flags) },\n 22:\t};\n 23:\t\n 24:\tstatic int rmnet_is_real_dev_registered(const struct net_device *real_dev)\n 25:\t{\n 26:\t\treturn rcu_access_pointer(real_dev-\u003erx_handler) == rmnet_rx_handler;\n 27:\t}\n"
} |
| 91/3 | 2026/10/08 01:27 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 83920 output: 40 thoughts: 65 Thoughts: Here's my thought process, as requested: **Checking RMNET Flags Size and Usage** Okay, so I see that `IFLA_RMNET_FLAGS` has its length set to `sizeof(struct ifla_rmnet_flags)`. That seems straightforward enough. But hold on... something feels slightly off. I need to be absolutely certain this size is handled correctly throughout the relevant code. My mind immediately jumps to `rmnet_fill_info`. Did the recent patch I reviewed potentially alter how that function interacts with the `IFLA_RMNET_FLAGS` attribute? It's a key area to scrutinize. Let me quickly double-check the `rmnet_fill_info` implementation to ensure everything is still aligned, particularly now after the patch. I need to make sure the size calculations and attribute filling are still consistent and accurate. I'm going to carefully review that function and look for anything that might need adjustment. |
| 92/3 | 2026/10/08 01:27 | tool | grepper |
0mArgs:{
"Expression": "rmnet_fill_info",
"PathPrefixes": [
"drivers/net/ethernet/qualcomm/rmnet/"
]
}Results: {
"Output": "drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=417=static size_t rmnet_get_size(const struct net_device *dev)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-425-\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:426:static int rmnet_fill_info(struct sk_buff *skb, const struct net_device *dev)\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-427-{\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=448=struct rtnl_link_ops rmnet_link_ops __read_mostly = {\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-458-\t.policy\t\t= rmnet_policy,\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:459:\t.fill_info\t= rmnet_fill_info,\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-460-};\n"
} |
| 93/3 | 2026/10/08 01:27 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 84529 output: 47 thoughts: 21 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Diving into `rmnet_fill_info`** Alright, let's get down to brass tacks. I need to understand what's happening with RMNET configuration, so I'm going to dig into the `rmnet_fill_info` function. Specifically, I'm heading over to `rmnet_config.c`. This function is likely a critical piece of the puzzle for understanding how the RMNET interface gets populated with its vital parameters. I expect it's going to be the central point where the interface’s attributes, such as MTU, IP address, and link speed get set, possibly based on profile, modem, or network configurations. Let’s see what goodies it's packing. I need to be ready to understand the data structures and how they're used. I suspect this will involve bitfields, structures and pointers. Okay, let's start reading. |
| 94/3 | 2026/10/08 01:27 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c",
"FirstLine": 425,
"LineCount": 25
}Results: {
"Contents": " 425:\t\n 426:\tstatic int rmnet_fill_info(struct sk_buff *skb, const struct net_device *dev)\n 427:\t{\n 428:\t\tconst struct rmnet_priv *priv = netdev_priv(dev);\n 429:\t\tconst struct rmnet_port *port;\n 430:\t\tstruct ifla_rmnet_flags f;\n 431:\t\n 432:\t\tif (nla_put_u16(skb, IFLA_RMNET_MUX_ID, READ_ONCE(priv-\u003emux_id)))\n 433:\t\t\treturn -EMSGSIZE;\n 434:\t\n 435:\t\trcu_read_lock();\n 436:\t\tport = rmnet_get_port_rcu(priv-\u003ereal_dev);\n 437:\t\tf.flags = port ? READ_ONCE(port-\u003edata_format) : 0;\n 438:\t\trcu_read_unlock();\n 439:\t\n 440:\t\tf.mask = ~0;\n 441:\t\n 442:\t\tif (nla_put(skb, IFLA_RMNET_FLAGS, sizeof(f), \u0026f))\n 443:\t\t\treturn -EMSGSIZE;\n 444:\t\n 445:\t\treturn 0;\n 446:\t}\n 447:\t\n 448:\tstruct rtnl_link_ops rmnet_link_ops __read_mostly = {\n 449:\t\t.kind\t\t= \"rmnet\",\n"
} |
| 95/3 | 2026/10/08 01:27 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 85221 output: 22 thoughts: 58 Thoughts: Here's my summary, as though I'm thinking through this myself: **Investigating a Potential Issue with RMNET Flags** Okay, so `rmnet_fill_info` hasn't been touched, which is a good starting point. But I've got a bit of a head-scratcher here. Both `f.flags` and `f.mask` are being set, even though the core function itself didn't change. That screams potential data corruption or an unexpected interaction elsewhere. My immediate concern is with the `struct ifla_rmnet_flags`. It's pretty likely that's where the problem is originating. Time to drill down and see if there are any obvious issues there, particularly around padding or unexpected bit shifts. Maybe there's a struct definition that's off, or something is writing to memory it shouldn't be. Let's get a look at that struct definition first. |
| 96/3 | 2026/10/08 01:27 | tool | grepper |
0mArgs:{
"Expression": "struct ifla_rmnet_flags"
}Results: {
"Output": "Documentation/networking/device_drivers/cellular/qualcomm/rmnet.rst=314=pipeline are set via the ``IFLA_RMNET_FLAGS`` attribute\nDocumentation/networking/device_drivers/cellular/qualcomm/rmnet.rst:315:(``struct ifla_rmnet_flags``).\nDocumentation/networking/device_drivers/cellular/qualcomm/rmnet.rst-316-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=19=static const struct nla_policy rmnet_policy[IFLA_RMNET_MAX + 1] = {\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-20-\t[IFLA_RMNET_MUX_ID]\t= { .type = NLA_U16 },\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:21:\t[IFLA_RMNET_FLAGS]\t= { .len = sizeof(struct ifla_rmnet_flags) },\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-22-};\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=145=static int rmnet_newlink(struct net_device *dev,\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-171-\tif (data[IFLA_RMNET_FLAGS]) {\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:172:\t\tstruct ifla_rmnet_flags *flags;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-173-\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=338=static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-342-\tstruct rmnet_priv *priv = netdev_priv(dev);\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:343:\tstruct ifla_rmnet_flags *flags;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-344-\tstruct net_device *real_dev;\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=417=static size_t rmnet_get_size(const struct net_device *dev)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-422-\t\t/* IFLA_RMNET_FLAGS */\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:423:\t\tnla_total_size(sizeof(struct ifla_rmnet_flags));\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-424-}\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c=426=static int rmnet_fill_info(struct sk_buff *skb, const struct net_device *dev)\n--\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-429-\tconst struct rmnet_port *port;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:430:\tstruct ifla_rmnet_flags f;\ndrivers/net/ethernet/qualcomm/rmnet/rmnet_config.c-431-\n--\ninclude/uapi/linux/if_link.h=2027=enum {\n--\ninclude/uapi/linux/if_link.h-2035-\ninclude/uapi/linux/if_link.h:2036:struct ifla_rmnet_flags {\ninclude/uapi/linux/if_link.h-2037-\t__u32\tflags;\n--\ntools/include/uapi/linux/if_link.h=1946=enum {\n--\ntools/include/uapi/linux/if_link.h-1954-\ntools/include/uapi/linux/if_link.h:1955:struct ifla_rmnet_flags {\ntools/include/uapi/linux/if_link.h-1956-\t__u32\tflags;\n"
} |
| 97/3 | 2026/10/08 01:27 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 86597 output: 451 thoughts: 3421 Thoughts: **KMSAN Assessment: RMNET MAPv5 Coalescing Implementation**
Alright, let's break this down systematically. I've reviewed the code changes for the RMNET MAPv5 coalescing implementation with a keen eye for potential memory safety issues, specifically focusing on whether KMSAN is actually needed here. The primary focus is on the handling of network packets, the allocation and manipulation of SKBs (socket buffer), the extraction of data from coalesced headers, and the presentation of statistics.
First, I examined the `struct ifla_rmnet_flags`. It looks like a straightforward structure with 8 bytes: `flags` and `mask`, each a `__u32`. No padding issues there. That's a good starting point.
Next, the `rmnet_map_v5_coal_header` is where the core logic comes in. We have a header with several fields. The code parses packet headers received "over the wire". I've scrutinized this structure and the associated handling functions. My goal is to determine if there's any risk of uninitialized memory being read, used in calculations, or, critically, passed to user space.
I've carefully examined all the code changes across the listed files:
1. **`rmnet_config.c`:** The data format validation and updates were assessed. I need to make sure MTU is calculated correctly. No immediate KMSAN concerns are present since the logic appears straightforward integer based with validation performed.
2. **`rmnet_config.h`:** Introduction of per-CPU stats and removal of legacy stats. Here, I traced all uses of the new `rmnet_pcpu_priv_stats` structures. The addition of per-CPU statistics requires careful tracking of how these structures are allocated, initialized, and accessed. Thankfully, `alloc_percpu()` guarantees zero-initialization. This is a very good sign. I checked that stats are correctly updated and aggregated.
3. **`rmnet_handlers.c`:** SKB (socket buffer) handling is a major focus here. The `rmnet_deliver_skb_list` and `__rmnet_map_ingress_handler` functions, particularly the usage of `sk_buff_head` and `skb_queue_head_init`, demand scrutiny. I needed to verify that the SKBs are properly initialized, and that there are no uninitialized variables used in the SKB queueing/dequeuing process.
4. **`rmnet_map.h`:** Checked for any new enumerations or function declarations that might suggest hidden state or initialization issues.
5. **`rmnet_map_data.c`:** This is the heart of the packet processing logic. Extensive review was conducted here to cover the following:
* Stats tracking using `pcpu_ptr`. I tracked all uses of the per-cpu stats, ensuring there are no race conditions or uninitialized values being read.
* Coalescing header length checks, which I understand are essential to the algorithm. This file's implementation, and how the values are extracted. The goal is to verify that these fields are valid and that any derived values are computed correctly to avoid over-reads or other memory access errors.
* Metadata struct `coal_meta` using `memset`. This is good practice. I need to confirm all uses correctly initialize this to avoid info-leaks.
* `gso_type`, `gso_size`, `gso_segs` settings. GSO (Generic Segmentation Offload) is sensitive and needs correct initialization.
* Partial checksum and its usage. I needed to verify how the partial checksum is computed and applied. If partial checksum is not initialized or invalid, this could potentially create a vulnerability.
* `rmnet_map_v5_get_num_nlos`, `rmnet_map_v5_set_nlos`, `rmnet_map_v5_csum_fixup` functions. These required a very close review to ensure the bits from `coal_hdr` are correctly read and written.
* `__rmnet_map_segment_coal_skb`: This function has many critical steps, so I needed to verify that the headers and payload are properly populated, the partial csum is set, and the stats are updated. No part could be skipped.
* Header parsing (`rmnet_map_coal_parse_ip_hdr`, `rmnet_map_coal_parse_trans_hdr`), bounds validation (`rmnet_map_coal_validate_bounds`), and GRO fast-path. These paths need to be error-checked and validated.
* The `rmnet_map_data_check_coal_header` function: I need to
|
| 98/3 | 2026/10/08 01:28 | tool | set-results |
0mArgs:{
"KMSANReasoning": "The patch series implements MAPv5 packet coalescing support and per-CPU diagnostic statistics for the Qualcomm rmnet driver.\n\nKASAN vs KMSAN applicability:\n- Potential risks introduced by these changes center around incoming packet parsing: decoding Number-Length Object (NLO) headers, calculating packet boundaries, reconstructing logical segments from coalesced frames, and manipulating SKB headroom/tailroom. Any bugs in these areas (such as buffer over-reads or out-of-bounds pointer arithmetic on malformed network packets) are out-of-bounds accesses detected by KASAN.\n- KMSAN is not justified here because there are no uninitialized memory risks:\n 1. All new or modified stack variables (e.g., `struct rmnet_map_coal_metadata coal_meta`, `struct rmnet_priv_stats total_stats`) are explicitly zero-initialized via `memset()` or `{ }`.\n 2. Out-parameters in helper functions (e.g., `rmnet_map_data_check_coal_header`) are unconditionally populated on success and callers abort on error before consuming them.\n 3. Statistics reported to userspace or netlink/ethtool (`rmnet_get_ethtool_stats`, `rmnet_get_stats64`, and `rmnet_get_queue_stats_rx`) are aggregated into zero-initialized structures; the ethtool buffer length matches the field count without padding gaps.\n 4. Per-CPU statistics structures are allocated with `alloc_percpu()` (which zeroes memory).\n 5. Segment SKBs allocated via `alloc_skb()` are completely filled with payload and restored headers via `skb_put_data()`, `skb_push()`, and `memcpy()`, leaving no uninitialized data bytes.\n\nBecause the risks are bounded to buffer boundaries and logic validation (monitored by KASAN) and no uninitialized memory or info-leak vectors are introduced, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false
}Results: {
"KMSANReasoning": "The patch series implements MAPv5 packet coalescing support and per-CPU diagnostic statistics for the Qualcomm rmnet driver.\n\nKASAN vs KMSAN applicability:\n- Potential risks introduced by these changes center around incoming packet parsing: decoding Number-Length Object (NLO) headers, calculating packet boundaries, reconstructing logical segments from coalesced frames, and manipulating SKB headroom/tailroom. Any bugs in these areas (such as buffer over-reads or out-of-bounds pointer arithmetic on malformed network packets) are out-of-bounds accesses detected by KASAN.\n- KMSAN is not justified here because there are no uninitialized memory risks:\n 1. All new or modified stack variables (e.g., `struct rmnet_map_coal_metadata coal_meta`, `struct rmnet_priv_stats total_stats`) are explicitly zero-initialized via `memset()` or `{ }`.\n 2. Out-parameters in helper functions (e.g., `rmnet_map_data_check_coal_header`) are unconditionally populated on success and callers abort on error before consuming them.\n 3. Statistics reported to userspace or netlink/ethtool (`rmnet_get_ethtool_stats`, `rmnet_get_stats64`, and `rmnet_get_queue_stats_rx`) are aggregated into zero-initialized structures; the ethtool buffer length matches the field count without padding gaps.\n 4. Per-CPU statistics structures are allocated with `alloc_percpu()` (which zeroes memory).\n 5. Segment SKBs allocated via `alloc_skb()` are completely filled with payload and restored headers via `skb_put_data()`, `skb_push()`, and `memcpy()`, leaving no uninitialized data bytes.\n\nBecause the risks are bounded to buffer boundaries and logic validation (monitored by KASAN) and no uninitialized memory or info-leak vectors are introduced, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|