net/mlx5e: Use PARTIAL_GSO for UDP segmentation
[sfrench/cifs-2.6.git] / drivers / net / ethernet / mellanox / mlx5 / core / en_main.c
index bbd2fd0b2e064126e947991ba07a024ebd1a1cb6..dccde18f6170f5e67cc2f03534318329badf4a37 100644 (file)
@@ -349,7 +349,8 @@ static int mlx5e_rq_alloc_mpwqe_info(struct mlx5e_rq *rq,
 {
        int wq_sz = mlx5_wq_ll_get_size(&rq->mpwqe.wq);
 
-       rq->mpwqe.info = kvzalloc_node(wq_sz * sizeof(*rq->mpwqe.info),
+       rq->mpwqe.info = kvzalloc_node(array_size(wq_sz,
+                                                 sizeof(*rq->mpwqe.info)),
                                       GFP_KERNEL, cpu_to_node(c->cpu));
        if (!rq->mpwqe.info)
                return -ENOMEM;
@@ -969,7 +970,7 @@ static int mlx5e_alloc_xdpsq_db(struct mlx5e_xdpsq *sq, int numa)
 {
        int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
 
-       sq->db.di = kvzalloc_node(sizeof(*sq->db.di) * wq_sz,
+       sq->db.di = kvzalloc_node(array_size(wq_sz, sizeof(*sq->db.di)),
                                  GFP_KERNEL, numa);
        if (!sq->db.di) {
                mlx5e_free_xdpsq_db(sq);
@@ -1028,7 +1029,8 @@ static int mlx5e_alloc_icosq_db(struct mlx5e_icosq *sq, int numa)
 {
        u8 wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
 
-       sq->db.ico_wqe = kvzalloc_node(sizeof(*sq->db.ico_wqe) * wq_sz,
+       sq->db.ico_wqe = kvzalloc_node(array_size(wq_sz,
+                                                 sizeof(*sq->db.ico_wqe)),
                                       GFP_KERNEL, numa);
        if (!sq->db.ico_wqe)
                return -ENOMEM;
@@ -1083,9 +1085,11 @@ static int mlx5e_alloc_txqsq_db(struct mlx5e_txqsq *sq, int numa)
        int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
        int df_sz = wq_sz * MLX5_SEND_WQEBB_NUM_DS;
 
-       sq->db.dma_fifo = kvzalloc_node(df_sz * sizeof(*sq->db.dma_fifo),
+       sq->db.dma_fifo = kvzalloc_node(array_size(df_sz,
+                                                  sizeof(*sq->db.dma_fifo)),
                                        GFP_KERNEL, numa);
-       sq->db.wqe_info = kvzalloc_node(wq_sz * sizeof(*sq->db.wqe_info),
+       sq->db.wqe_info = kvzalloc_node(array_size(wq_sz,
+                                                  sizeof(*sq->db.wqe_info)),
                                        GFP_KERNEL, numa);
        if (!sq->db.dma_fifo || !sq->db.wqe_info) {
                mlx5e_free_txqsq_db(sq);
@@ -4192,7 +4196,6 @@ static int mlx5e_xdp(struct net_device *dev, struct netdev_bpf *xdp)
                return mlx5e_xdp_set(dev, xdp->prog);
        case XDP_QUERY_PROG:
                xdp->prog_id = mlx5e_xdp_query(dev);
-               xdp->prog_attached = !!xdp->prog_id;
                return 0;
        default:
                return -EINVAL;
@@ -4535,7 +4538,6 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
        netdev->hw_features      |= NETIF_F_HW_VLAN_STAG_TX;
 
        if (mlx5e_vxlan_allowed(mdev) || MLX5_CAP_ETH(mdev, tunnel_stateless_gre)) {
-               netdev->hw_features     |= NETIF_F_GSO_PARTIAL;
                netdev->hw_enc_features |= NETIF_F_IP_CSUM;
                netdev->hw_enc_features |= NETIF_F_IPV6_CSUM;
                netdev->hw_enc_features |= NETIF_F_TSO;
@@ -4560,6 +4562,11 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
                                                NETIF_F_GSO_GRE_CSUM;
        }
 
+       netdev->hw_features                      |= NETIF_F_GSO_PARTIAL;
+       netdev->gso_partial_features             |= NETIF_F_GSO_UDP_L4;
+       netdev->hw_features                      |= NETIF_F_GSO_UDP_L4;
+       netdev->features                         |= NETIF_F_GSO_UDP_L4;
+
        mlx5_query_port_fcs(mdev, &fcs_supported, &fcs_enabled);
 
        if (fcs_supported)
@@ -4592,9 +4599,6 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
        netdev->features         |= NETIF_F_HIGHDMA;
        netdev->features         |= NETIF_F_HW_VLAN_STAG_FILTER;
 
-       netdev->features         |= NETIF_F_GSO_UDP_L4;
-       netdev->hw_features      |= NETIF_F_GSO_UDP_L4;
-
        netdev->priv_flags       |= IFF_UNICAST_FLT;
 
        mlx5e_set_netdev_dev_addr(netdev);