Skip to content

Commit

Permalink
Add support for debugnet in mlx5en(4).
Browse files Browse the repository at this point in the history
MFC after:	1 week
Sponsored by:	Mellanox Technologies
  • Loading branch information
hselasky committed Feb 12, 2020
1 parent fb179da commit 01dff33
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions sys/dev/mlx5/mlx5_en/mlx5_en_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <sys/sockio.h>
#include <machine/atomic.h>

#include <net/debugnet.h>

#ifndef ETH_DRIVER_VERSION
#define ETH_DRIVER_VERSION "3.5.2"
#endif
Expand Down Expand Up @@ -399,6 +401,8 @@ static const struct media mlx5e_ext_mode_table[MLX5E_EXT_LINK_SPEEDS_NUMBER][MLX
},
};

DEBUGNET_DEFINE(mlx5_en);

MALLOC_DEFINE(M_MLX5EN, "MLX5EN", "MLX5 Ethernet");

static void
Expand Down Expand Up @@ -4444,6 +4448,9 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
/* Set autoselect by default */
ifmedia_set(&priv->media, IFM_ETHER | IFM_AUTO | IFM_FDX |
IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE);

DEBUGNET_SET(ifp, mlx5_en);

ether_ifattach(ifp, dev_addr);

/* Register for VLAN events */
Expand Down Expand Up @@ -4591,6 +4598,71 @@ mlx5e_destroy_ifp(struct mlx5_core_dev *mdev, void *vpriv)
free(priv, M_MLX5EN);
}

#ifdef DEBUGNET
static void
mlx5_en_debugnet_init(struct ifnet *dev, int *nrxr, int *ncl, int *clsize)
{
struct mlx5e_priv *priv = if_getsoftc(dev);

PRIV_LOCK(priv);
*nrxr = priv->params.num_channels;
*ncl = DEBUGNET_MAX_IN_FLIGHT;
*clsize = MLX5E_MAX_RX_BYTES;
PRIV_UNLOCK(priv);
}

static void
mlx5_en_debugnet_event(struct ifnet *dev, enum debugnet_ev event)
{
}

static int
mlx5_en_debugnet_transmit(struct ifnet *dev, struct mbuf *m)
{
struct mlx5e_priv *priv = if_getsoftc(dev);
struct mlx5e_sq *sq;
int err;

if ((if_getdrvflags(dev) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
IFF_DRV_RUNNING || (priv->media_status_last & IFM_ACTIVE) == 0)
return (ENOENT);

sq = &priv->channel[0].sq[0];

if (sq->running == 0) {
m_freem(m);
return (ENOENT);
}

if (mlx5e_sq_xmit(sq, &m) != 0) {
m_freem(m);
err = ENOBUFS;
} else {
err = 0;
}

if (likely(sq->doorbell.d64 != 0)) {
mlx5e_tx_notify_hw(sq, sq->doorbell.d32, 0);
sq->doorbell.d64 = 0;
}
return (err);
}

static int
mlx5_en_debugnet_poll(struct ifnet *dev, int count)
{
struct mlx5e_priv *priv = if_getsoftc(dev);

if ((if_getdrvflags(dev) & IFF_DRV_RUNNING) == 0 ||
(priv->media_status_last & IFM_ACTIVE) == 0)
return (ENOENT);

mlx5_poll_interrupts(priv->mdev);

return (0);
}
#endif /* DEBUGNET */

static void *
mlx5e_get_ifp(void *vpriv)
{
Expand Down

0 comments on commit 01dff33

Please sign in to comment.