@@ -494,7 +494,8 @@ mlxsw_pci_sync_for_cpu(const struct mlxsw_pci_queue *q,
static struct sk_buff *
mlxsw_pci_rdq_build_skb(struct mlxsw_pci_queue *q,
- const struct mlxsw_pci_rx_pkt_info *rx_pkt_info)
+ const struct mlxsw_pci_rx_pkt_info *rx_pkt_info,
+ struct net_device *netdev)
{
unsigned int linear_data_size;
struct sk_buff *skb;
@@ -513,7 +514,7 @@ mlxsw_pci_rdq_build_skb(struct mlxsw_pci_queue *q,
skb_put(skb, linear_data_size);
if (rx_pkt_info->num_sg_entries == 1)
- return skb;
+ goto out;
for (i = 1; i < rx_pkt_info->num_sg_entries; i++) {
unsigned int frag_size;
@@ -525,6 +526,10 @@ mlxsw_pci_rdq_build_skb(struct mlxsw_pci_queue *q,
page, 0, frag_size, PAGE_SIZE);
}
+out:
+ if (netdev)
+ skb->protocol = eth_type_trans(skb, netdev);
+
return skb;
}
@@ -814,6 +819,7 @@ static void mlxsw_pci_cqe_rdq_handle(struct mlxsw_pci *mlxsw_pci,
struct pci_dev *pdev = mlxsw_pci->pdev;
struct mlxsw_pci_queue_elem_info *elem_info;
struct mlxsw_rx_info rx_info = {};
+ struct mlxsw_pci_port *pci_port;
struct sk_buff *skb;
u16 byte_count;
int err;
@@ -851,7 +857,8 @@ static void mlxsw_pci_cqe_rdq_handle(struct mlxsw_pci *mlxsw_pci,
if (err)
goto out;
- skb = mlxsw_pci_rdq_build_skb(q, &rx_pkt_info);
+ pci_port = &mlxsw_pci->pci_ports[rx_info.local_port];
+ skb = mlxsw_pci_rdq_build_skb(q, &rx_pkt_info, pci_port->netdev);
if (IS_ERR(skb)) {
dev_err_ratelimited(&pdev->dev, "Failed to build skb for RDQ\n");
mlxsw_pci_rdq_pages_recycle(q, rx_pkt_info.pages,
@@ -2340,15 +2340,12 @@ void mlxsw_sp_rx_listener_no_mark_func(struct sk_buff *skb,
return;
}
- skb->dev = mlxsw_sp_port->dev;
-
pcpu_stats = this_cpu_ptr(mlxsw_sp_port->pcpu_stats);
u64_stats_update_begin(&pcpu_stats->syncp);
pcpu_stats->rx_packets++;
- pcpu_stats->rx_bytes += skb->len;
+ pcpu_stats->rx_bytes += skb->len + ETH_HLEN;
u64_stats_update_end(&pcpu_stats->syncp);
- skb->protocol = eth_type_trans(skb, skb->dev);
napi_gro_receive(mlxsw_skb_cb(skb)->rx_md_info.napi, skb);
}
@@ -72,16 +72,12 @@ static int mlxsw_sp_rx_listener(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
return -EINVAL;
}
- skb->dev = mlxsw_sp_port->dev;
-
pcpu_stats = this_cpu_ptr(mlxsw_sp_port->pcpu_stats);
u64_stats_update_begin(&pcpu_stats->syncp);
pcpu_stats->rx_packets++;
- pcpu_stats->rx_bytes += skb->len;
+ pcpu_stats->rx_bytes += skb->len + ETH_HLEN;
u64_stats_update_end(&pcpu_stats->syncp);
- skb->protocol = eth_type_trans(skb, skb->dev);
-
return 0;
}