]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mlxsw: Add mlxsw_txhdr_info structure
authorAmit Cohen <amcohen@nvidia.com>
Thu, 16 Jan 2025 16:38:14 +0000 (17:38 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sat, 18 Jan 2025 03:57:59 +0000 (19:57 -0800)
mlxsw_tx_info structure is used to store information that is needed to
process Tx completions when Tx time stamps are requested. A next patch
will move Tx header handling from spectrum.c to pci.c. For that, some
additional fields which are related to Tx should be passed to pci driver.

As preparation, create an extended structure, called mlxsw_txhdr_info,
and store mlxsw_tx_info inside. The new fields should not be added to
mlxsw_tx_info structure as it is stored in the SKB control block which is
of limited size.

The next patch will extend the new structure with some fields which are
needed in order to construct Tx header.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Link: https://patch.msgid.link/93aed1961f046f79f46869bab37a3faa5027751d.1737044384.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/core.c
drivers/net/ethernet/mellanox/mlxsw/core.h
drivers/net/ethernet/mellanox/mlxsw/i2c.c
drivers/net/ethernet/mellanox/mlxsw/pci.c
drivers/net/ethernet/mellanox/mlxsw/spectrum.c

index 4a79c0d7e7ad8546aae5e51f7c23ce7ee8642674..a3c032da4b4b3c541a6684414e459e20e3d912e8 100644 (file)
@@ -677,7 +677,7 @@ struct mlxsw_reg_trans {
        struct list_head bulk_list;
        struct mlxsw_core *core;
        struct sk_buff *tx_skb;
-       struct mlxsw_tx_info tx_info;
+       struct mlxsw_txhdr_info txhdr_info;
        struct delayed_work timeout_dw;
        unsigned int retries;
        u64 tid;
@@ -742,7 +742,7 @@ static int mlxsw_emad_transmit(struct mlxsw_core *mlxsw_core,
                            skb->len - mlxsw_core->driver->txhdr_len);
 
        atomic_set(&trans->active, 1);
-       err = mlxsw_core_skb_transmit(mlxsw_core, skb, &trans->tx_info);
+       err = mlxsw_core_skb_transmit(mlxsw_core, skb, &trans->txhdr_info);
        if (err) {
                dev_kfree_skb(skb);
                return err;
@@ -984,8 +984,8 @@ static int mlxsw_emad_reg_access(struct mlxsw_core *mlxsw_core,
        list_add_tail(&trans->bulk_list, bulk_list);
        trans->core = mlxsw_core;
        trans->tx_skb = skb;
-       trans->tx_info.local_port = MLXSW_PORT_CPU_PORT;
-       trans->tx_info.is_emad = true;
+       trans->txhdr_info.tx_info.local_port = MLXSW_PORT_CPU_PORT;
+       trans->txhdr_info.tx_info.is_emad = true;
        INIT_DELAYED_WORK(&trans->timeout_dw, mlxsw_emad_trans_timeout_work);
        trans->tid = tid;
        init_completion(&trans->completion);
@@ -995,7 +995,7 @@ static int mlxsw_emad_reg_access(struct mlxsw_core *mlxsw_core,
        trans->type = type;
 
        mlxsw_emad_construct(mlxsw_core, skb, reg, payload, type, trans->tid);
-       mlxsw_core->driver->txhdr_construct(skb, &trans->tx_info);
+       mlxsw_core->driver->txhdr_construct(skb, &trans->txhdr_info.tx_info);
 
        spin_lock_bh(&mlxsw_core->emad.trans_list_lock);
        list_add_tail_rcu(&trans->list, &mlxsw_core->emad.trans_list);
@@ -2330,10 +2330,10 @@ bool mlxsw_core_skb_transmit_busy(struct mlxsw_core *mlxsw_core,
 EXPORT_SYMBOL(mlxsw_core_skb_transmit_busy);
 
 int mlxsw_core_skb_transmit(struct mlxsw_core *mlxsw_core, struct sk_buff *skb,
-                           const struct mlxsw_tx_info *tx_info)
+                           const struct mlxsw_txhdr_info *txhdr_info)
 {
        return mlxsw_core->bus->skb_transmit(mlxsw_core->bus_priv, skb,
-                                            tx_info);
+                                            txhdr_info);
 }
 EXPORT_SYMBOL(mlxsw_core_skb_transmit);
 
index 24c3ff6fcf71be4ee0a33df54e52e82fd1536319..cd33ceb2154bbe68b83e0092b64af5e8a289ad22 100644 (file)
@@ -72,6 +72,10 @@ struct mlxsw_tx_info {
        bool is_emad;
 };
 
+struct mlxsw_txhdr_info {
+       struct mlxsw_tx_info tx_info;
+};
+
 struct mlxsw_rx_md_info {
        struct napi_struct *napi;
        u32 cookie_index;
@@ -95,7 +99,7 @@ struct mlxsw_rx_md_info {
 bool mlxsw_core_skb_transmit_busy(struct mlxsw_core *mlxsw_core,
                                  const struct mlxsw_tx_info *tx_info);
 int mlxsw_core_skb_transmit(struct mlxsw_core *mlxsw_core, struct sk_buff *skb,
-                           const struct mlxsw_tx_info *tx_info);
+                           const struct mlxsw_txhdr_info *txhdr_info);
 void mlxsw_core_ptp_transmitted(struct mlxsw_core *mlxsw_core,
                                struct sk_buff *skb, u16 local_port);
 
@@ -487,7 +491,7 @@ struct mlxsw_bus {
        bool (*skb_transmit_busy)(void *bus_priv,
                                  const struct mlxsw_tx_info *tx_info);
        int (*skb_transmit)(void *bus_priv, struct sk_buff *skb,
-                           const struct mlxsw_tx_info *tx_info);
+                           const struct mlxsw_txhdr_info *txhdr_info);
        int (*cmd_exec)(void *bus_priv, u16 opcode, u8 opcode_mod,
                        u32 in_mod, bool out_mbox_direct,
                        char *in_mbox, size_t in_mbox_size,
index 1e150ce1c73a4062ca2067fcf75b90f7c40eec38..f9f565c1036d658f4b463d701be52dee55eecbf9 100644 (file)
@@ -516,7 +516,7 @@ static bool mlxsw_i2c_skb_transmit_busy(void *bus_priv,
 }
 
 static int mlxsw_i2c_skb_transmit(void *bus_priv, struct sk_buff *skb,
-                                 const struct mlxsw_tx_info *tx_info)
+                                 const struct mlxsw_txhdr_info *txhdr_info)
 {
        return 0;
 }
index 0863dca2fc0be32b524b8157e7c61032a97bd897..e8e0a06cd4e0f34b5d7b9a693a807c4406be6c3d 100644 (file)
@@ -2122,7 +2122,7 @@ static bool mlxsw_pci_skb_transmit_busy(void *bus_priv,
 }
 
 static int mlxsw_pci_skb_transmit(void *bus_priv, struct sk_buff *skb,
-                                 const struct mlxsw_tx_info *tx_info)
+                                 const struct mlxsw_txhdr_info *txhdr_info)
 {
        struct mlxsw_pci *mlxsw_pci = bus_priv;
        struct mlxsw_pci_queue *q;
@@ -2137,7 +2137,7 @@ static int mlxsw_pci_skb_transmit(void *bus_priv, struct sk_buff *skb,
                        return err;
        }
 
-       q = mlxsw_pci_sdq_pick(mlxsw_pci, tx_info);
+       q = mlxsw_pci_sdq_pick(mlxsw_pci, &txhdr_info->tx_info);
        spin_lock_bh(&q->lock);
        elem_info = mlxsw_pci_queue_elem_info_producer_get(q);
        if (!elem_info) {
@@ -2145,7 +2145,7 @@ static int mlxsw_pci_skb_transmit(void *bus_priv, struct sk_buff *skb,
                err = -EAGAIN;
                goto unlock;
        }
-       mlxsw_skb_cb(skb)->tx_info = *tx_info;
+       mlxsw_skb_cb(skb)->tx_info = txhdr_info->tx_info;
        elem_info->sdq.skb = skb;
 
        wqe = elem_info->elem;
index aa71993daf282dcf17e62a243870e225c7036c97..3bd6230307aa69fc4ff6c9776ddfe958274967a2 100644 (file)
@@ -721,16 +721,16 @@ static netdev_tx_t mlxsw_sp_port_xmit(struct sk_buff *skb,
        struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
        struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
        struct mlxsw_sp_port_pcpu_stats *pcpu_stats;
-       const struct mlxsw_tx_info tx_info = {
-               .local_port = mlxsw_sp_port->local_port,
-               .is_emad = false,
+       const struct mlxsw_txhdr_info txhdr_info = {
+               .tx_info.local_port = mlxsw_sp_port->local_port,
+               .tx_info.is_emad = false,
        };
        u64 len;
        int err;
 
        memset(skb->cb, 0, sizeof(struct mlxsw_skb_cb));
 
-       if (mlxsw_core_skb_transmit_busy(mlxsw_sp->core, &tx_info))
+       if (mlxsw_core_skb_transmit_busy(mlxsw_sp->core, &txhdr_info.tx_info))
                return NETDEV_TX_BUSY;
 
        if (eth_skb_pad(skb)) {
@@ -739,7 +739,7 @@ static netdev_tx_t mlxsw_sp_port_xmit(struct sk_buff *skb,
        }
 
        err = mlxsw_sp_txhdr_handle(mlxsw_sp->core, mlxsw_sp_port, skb,
-                                   &tx_info);
+                                   &txhdr_info.tx_info);
        if (err)
                return NETDEV_TX_OK;
 
@@ -751,7 +751,7 @@ static netdev_tx_t mlxsw_sp_port_xmit(struct sk_buff *skb,
        /* Due to a race we might fail here because of a full queue. In that
         * unlikely case we simply drop the packet.
         */
-       err = mlxsw_core_skb_transmit(mlxsw_sp->core, skb, &tx_info);
+       err = mlxsw_core_skb_transmit(mlxsw_sp->core, skb, &txhdr_info);
 
        if (!err) {
                pcpu_stats = this_cpu_ptr(mlxsw_sp_port->pcpu_stats);