| From 1db8c9217928b36555c247bcf91a4c648fe9ad2f Mon Sep 17 00:00:00 2001 |
| From: Petr Machata <petrm@mellanox.com> |
| Date: Sun, 30 Jun 2019 09:04:52 +0300 |
| Subject: [PATCH] mlxsw: core: Add support for using SKB control buffer |
| |
| commit d7cd206dbfb25efc5f06ea3c595074a51d48d00a upstream. |
| |
| The SKB control buffer is useful (and used) for bookkeeping of information |
| related to that SKB. Add helpers so that the mlxsw driver(s) can safely use |
| the buffer as well. The structure is currently empty, individual users will |
| add members to it as necessary. |
| |
| Note that SKB allocation functions already clear the buffer, so the cleanup |
| is only necessary when ndo_start_xmit is called. |
| |
| Signed-off-by: Petr Machata <petrm@mellanox.com> |
| Acked-by: Jiri Pirko <jiri@mellanox.com> |
| Signed-off-by: Ido Schimmel <idosch@mellanox.com> |
| Signed-off-by: David S. Miller <davem@davemloft.net> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h |
| index e3832cb5bdda..685ed82b123f 100644 |
| --- a/drivers/net/ethernet/mellanox/mlxsw/core.h |
| +++ b/drivers/net/ethernet/mellanox/mlxsw/core.h |
| @@ -409,4 +409,13 @@ enum mlxsw_devlink_param_id { |
| MLXSW_DEVLINK_PARAM_ID_ACL_REGION_REHASH_INTERVAL, |
| }; |
| |
| +struct mlxsw_skb_cb { |
| +}; |
| + |
| +static inline struct mlxsw_skb_cb *mlxsw_skb_cb(struct sk_buff *skb) |
| +{ |
| + BUILD_BUG_ON(sizeof(mlxsw_skb_cb) > sizeof(skb->cb)); |
| + return (struct mlxsw_skb_cb *) skb->cb; |
| +} |
| + |
| #endif |
| diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c |
| index d51442e63aba..e1a9ce611387 100644 |
| --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c |
| +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c |
| @@ -738,6 +738,8 @@ static netdev_tx_t mlxsw_sp_port_xmit(struct sk_buff *skb, |
| u64 len; |
| int err; |
| |
| + memset(skb->cb, 0, sizeof(struct mlxsw_skb_cb)); |
| + |
| if (mlxsw_core_skb_transmit_busy(mlxsw_sp->core, &tx_info)) |
| return NETDEV_TX_BUSY; |
| |
| diff --git a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c |
| index fc4f19167262..bdab96f5bc70 100644 |
| --- a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c |
| +++ b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c |
| @@ -299,6 +299,8 @@ static netdev_tx_t mlxsw_sx_port_xmit(struct sk_buff *skb, |
| u64 len; |
| int err; |
| |
| + memset(skb->cb, 0, sizeof(struct mlxsw_skb_cb)); |
| + |
| if (mlxsw_core_skb_transmit_busy(mlxsw_sx->core, &tx_info)) |
| return NETDEV_TX_BUSY; |
| |
| -- |
| 2.7.4 |
| |