From owner-svn-src-head@freebsd.org Wed Feb 12 10:03:26 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 119972333D5; Wed, 12 Feb 2020 10:03:26 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48HZwF6kTvz49k4; Wed, 12 Feb 2020 10:03:25 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C82F11F58F; Wed, 12 Feb 2020 10:03:25 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 01CA3PJ4042714; Wed, 12 Feb 2020 10:03:25 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 01CA3PZS042713; Wed, 12 Feb 2020 10:03:25 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202002121003.01CA3PZS042713@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 12 Feb 2020 10:03:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357802 - head/sys/dev/mlx5/mlx5_en X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: head/sys/dev/mlx5/mlx5_en X-SVN-Commit-Revision: 357802 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Feb 2020 10:03:26 -0000 Author: hselasky Date: Wed Feb 12 10:03:25 2020 New Revision: 357802 URL: https://svnweb.freebsd.org/changeset/base/357802 Log: Add support for debugnet in mlx5en(4). MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c ============================================================================== --- head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Wed Feb 12 09:58:19 2020 (r357801) +++ head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Wed Feb 12 10:03:25 2020 (r357802) @@ -33,6 +33,8 @@ #include #include +#include + #ifndef ETH_DRIVER_VERSION #define ETH_DRIVER_VERSION "3.5.2" #endif @@ -399,6 +401,8 @@ static const struct media mlx5e_ext_mode_table[MLX5E_E }, }; +DEBUGNET_DEFINE(mlx5_en); + MALLOC_DEFINE(M_MLX5EN, "MLX5EN", "MLX5 Ethernet"); static void @@ -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 */ @@ -4590,6 +4597,71 @@ mlx5e_destroy_ifp(struct mlx5_core_dev *mdev, void *vp if_free(ifp); 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)