sfc: more code refactoring
Subsystems (3)
cover sfc: more code refactoring
Splitting more of the driver code into different files, which will later be used in another driver for a new product.
This is a continuation to my previous patch series. There will be another series and a stand-alone patch as well after this.
This series in particular covers MCDI (management controller driver interface) code.
Alexandru-Mihai Maftei (9):
sfc: move some port link state/caps code
sfc: move some MCDI port utility functions
sfc: move more MCDI port code
sfc: move MCDI VI alloc/free code
sfc: move MCDI event queue management code
sfc: move MCDI transmit queue management code
sfc: move MCDI receive queue management code
sfc: conditioned some functionality
sfc: move MCDI logging device attribute
drivers/net/ethernet/sfc/Makefile | 4 +- drivers/net/ethernet/sfc/ef10.c | 355 ++------------ drivers/net/ethernet/sfc/efx.c | 55 +-- drivers/net/ethernet/sfc/efx_channels.c | 6 +- drivers/net/ethernet/sfc/efx_common.c | 86 +++- drivers/net/ethernet/sfc/efx_common.h | 8 + drivers/net/ethernet/sfc/mcdi_functions.c | 349 ++++++++++++++ drivers/net/ethernet/sfc/mcdi_functions.h | 2 +- drivers/net/ethernet/sfc/mcdi_port.c | 464 ------------------- drivers/net/ethernet/sfc/mcdi_port_common.c | 489 ++++++++++++++++++++ 10 files changed, 958 insertions(+), 860 deletions(-) create mode 100644 drivers/net/ethernet/sfc/mcdi_functions.c create mode 100644 drivers/net/ethernet/sfc/mcdi_port_common.c
Signature · 1 line
2.20.1
PATCH 1/9 sfc: move some port link state/caps code
The moved code handles MCDI port link state and capabilities.
--- drivers/net/ethernet/sfc/Makefile | 2 +- drivers/net/ethernet/sfc/efx.c | 15 -- drivers/net/ethernet/sfc/mcdi_port.c | 180 +---------------- drivers/net/ethernet/sfc/mcdi_port_common.c | 202 ++++++++++++++++++++ 4 files changed, 204 insertions(+), 195 deletions(-) create mode 100644 drivers/net/ethernet/sfc/mcdi_port_common.c
drivers/net/ethernet/sfc/Makefile +1 -1
@@ -3,7 +3,7 @@ sfc-y += efx.o efx_common.o efx_channels.o nic.o \ farch.o siena.o ef10.o \ tx.o tx_common.o rx.o rx_common.o \ selftest.o ethtool.o ptp.o tx_tso.o \ - mcdi.o mcdi_port.o \ + mcdi.o mcdi_port.o mcdi_port_common.o \ mcdi_mon.o sfc-$(CONFIG_SFC_MTD) += mtd.o sfc-$(CONFIG_SFC_SRIOV) += sriov.o siena_sriov.o ef10_sriov.o
drivers/net/ethernet/sfc/efx.c +0 -15
@@ -134,21 +134,6 @@ static int efx_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **xdpfs,* **************************************************************************/ -void efx_link_set_advertising (struct efx_nic *efx, -const unsigned long *advertising) -{ -memcpy (efx->link_advertising, advertising, -sizeof (__ETHTOOL_DECLARE_LINK_MODE_MASK ())); - - efx->link_advertising[0 ] |= ADVERTISED_Autoneg; -if (advertising[0 ] & ADVERTISED_Pause) - efx->wanted_fc |= (EFX_FC_TX |EFX_FC_RX ); -else - efx->wanted_fc &= ~(EFX_FC_TX |EFX_FC_RX ); -if (advertising[0 ] & ADVERTISED_Asym_Pause) - efx->wanted_fc ^=EFX_FC_TX ; -} -/* Equivalent to efx_link_set_advertising with all-zeroes, except does not * force the Autoneg bit on. */
drivers/net/ethernet/sfc/mcdi_port.c +1 -179
204 lines not on this page · raw message
drivers/net/ethernet/sfc/mcdi_port_common.c new file +202 -0
202 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 2/9 sfc: move some MCDI port utility functions
In reply to Alex Maftei (amaftei)They just convert between different sets of flags/registers. Some block comments were adjusted.
--- drivers/net/ethernet/sfc/mcdi_port.c | 148 -------------------- drivers/net/ethernet/sfc/mcdi_port_common.c | 148 ++++++++++++++++++++ 2 files changed, 148 insertions(+), 148 deletions(-)
drivers/net/ethernet/sfc/mcdi_port.c +0 -148
@@ -69,154 +69,6 @@ static int efx_mcdi_mdio_write(struct net_device *net_dev,return 0 ; } -u32 ethtool_linkset_to_mcdi_cap (const unsigned long *linkset) -{ -u32 result =0 ; - -#define TEST_BIT (name) test_bit(ETHTOOL_LINK_MODE_ ## name ## _BIT, \ - linkset) - - if (TEST_BIT(10baseT_Half)) - result |= (1 <<MC_CMD_PHY_CAP_10HDX_LBN ); - if (TEST_BIT(10baseT_Full)) - result |= (1 <<MC_CMD_PHY_CAP_10FDX_LBN ); - if (TEST_BIT(100baseT_Half)) - result |= (1 <<MC_CMD_PHY_CAP_100HDX_LBN ); - if (TEST_BIT(100baseT_Full)) - result |= (1 <<MC_CMD_PHY_CAP_100FDX_LBN ); - if (TEST_BIT(1000baseT_Half)) - result |= (1 <<MC_CMD_PHY_CAP_1000HDX_LBN ); - if (TEST_BIT(1000baseT_Full) || TEST_BIT(1000baseKX_Full)) - result |= (1 <<MC_CMD_PHY_CAP_1000FDX_LBN ); - if (TEST_BIT(10000baseT_Full) || TEST_BIT(10000baseKX4_Full)) - result |= (1 <<MC_CMD_PHY_CAP_10000FDX_LBN ); - if (TEST_BIT(40000baseCR4_Full) || TEST_BIT(40000baseKR4_Full)) - result |= (1 <<MC_CMD_PHY_CAP_40000FDX_LBN ); - if (TEST_BIT(100000baseCR4_Full)) - result |= (1 <<MC_CMD_PHY_CAP_100000FDX_LBN ); - if (TEST_BIT(25000baseCR_Full)) - result |= (1 <<MC_CMD_PHY_CAP_25000FDX_LBN ); - if (TEST_BIT(50000baseCR2_Full)) - result |= (1 <<MC_CMD_PHY_CAP_50000FDX_LBN ); -if (TEST_BIT (Pause)) - result |= (1 <<MC_CMD_PHY_CAP_PAUSE_LBN ); -if (TEST_BIT (Asym_Pause)) - result |= (1 <<MC_CMD_PHY_CAP_ASYM_LBN ); -if (TEST_BIT (Autoneg)) - result |= (1 <<MC_CMD_PHY_CAP_AN_LBN ); - -#undef TEST_BIT - -return result; -} - -u32 efx_get_mcdi_phy_flags (struct efx_nic *efx) -{ -struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; -enum efx_phy_mode mode, supported; -u32 flags; - -/* TODO: Advertise the capabilities supported by this PHY */ - supported =0 ; -if (phy_cfg->flags & (1 <<MC_CMD_GET_PHY_CFG_OUT_TXDIS_LBN )) - supported |=PHY_MODE_TX_DISABLED ; -if (phy_cfg->flags & (1 <<MC_CMD_GET_PHY_CFG_OUT_LOWPOWER_LBN )) - supported |=PHY_MODE_LOW_POWER ; -if (phy_cfg->flags & (1 <<MC_CMD_GET_PHY_CFG_OUT_POWEROFF_LBN )) - supported |=PHY_MODE_OFF ; - - mode = efx->phy_mode & supported; - - flags =0 ; -if (mode &PHY_MODE_TX_DISABLED ) - flags |= (1 <<MC_CMD_SET_LINK_IN_TXDIS_LBN ); -if (mode &PHY_MODE_LOW_POWER ) - flags |= (1 <<MC_CMD_SET_LINK_IN_LOWPOWER_LBN ); -if (mode &PHY_MODE_OFF ) - flags |= (1 <<MC_CMD_SET_LINK_IN_POWEROFF_LBN ); - -return flags; -} - -u8 mcdi_to_ethtool_media (u32 media) -{ -switch (media) { -case MC_CMD_MEDIA_XAUI : -case MC_CMD_MEDIA_CX4 : -case MC_CMD_MEDIA_KX4 : -return PORT_OTHER ; - -case MC_CMD_MEDIA_XFP : -case MC_CMD_MEDIA_SFP_PLUS : -case MC_CMD_MEDIA_QSFP_PLUS : -return PORT_FIBRE ; - -case MC_CMD_MEDIA_BASE_T : -return PORT_TP ; - -default : -return PORT_OTHER ; - } -} - -/* The semantics of the ethtool FEC mode bitmask are not well defined, -* particularly the meaning of combinations of bits. Which means we get to -* define our own semantics, as follows: -* OFF overrides any other bits, and means "disable all FEC" (with the -* exception of 25G KR4/CR4, where it is not possible to reject it if AN -* partner requests it). -* AUTO on its own means use cable requirements and link partner autoneg with -* fw-default preferences for the cable type. -* AUTO and either RS or BASER means use the specified FEC type if cable and -* link partner support it, otherwise autoneg/fw-default. -* RS or BASER alone means use the specified FEC type if cable and link partner -* support it and either requests it, otherwise no FEC. -* Both RS and BASER (whether AUTO or not) means use FEC if cable and link -* partner support it, preferring RS to BASER. -*/ -u32 ethtool_fec_caps_to_mcdi (u32 ethtool_cap) -{ -u32 ret =0 ; - -if (ethtool_cap ÐTOOL_FEC_OFF ) -return 0 ; - -if (ethtool_cap ÐTOOL_FEC_AUTO ) - ret |= (1 <<MC_CMD_PHY_CAP_BASER_FEC_LBN ) | - (1 <<MC_CMD_PHY_CAP_25G_BASER_FEC_LBN ) | - (1 <<MC_CMD_PHY_CAP_RS_FEC_LBN ); -if (ethtool_cap ÐTOOL_FEC_RS ) - ret |= (1 <<MC_CMD_PHY_CAP_RS_FEC_LBN ) | - (1 <<MC_CMD_PHY_CAP_RS_FEC_REQUESTED_LBN ); -if (ethtool_cap ÐTOOL_FEC_BASER ) - ret |= (1 <<MC_CMD_PHY_CAP_BASER_FEC_LBN ) | - (1 <<MC_CMD_PHY_CAP_25G_BASER_FEC_LBN ) | - (1 <<MC_CMD_PHY_CAP_BASER_FEC_REQUESTED_LBN ) | - (1 <<MC_CMD_PHY_CAP_25G_BASER_FEC_REQUESTED_LBN ); -return ret; -} - -/* Invert ethtool_fec_caps_to_mcdi. There are two combinations that function -* can never produce, (baser xor rs) and neither req; the implementation below -* maps both of those to AUTO. This should never matter, and it's not clear -* what a better mapping would be anyway. -*/ -u32 mcdi_fec_caps_to_ethtool (u32 caps,bool is_25g) -{ -bool rs = caps & (1 <<MC_CMD_PHY_CAP_RS_FEC_LBN ), - rs_req = caps & (1 <<MC_CMD_PHY_CAP_RS_FEC_REQUESTED_LBN ), - baser = is_25g ? caps & (1 <<MC_CMD_PHY_CAP_25G_BASER_FEC_LBN ) - : caps & (1 <<MC_CMD_PHY_CAP_BASER_FEC_LBN ), - baser_req = is_25g ? caps & (1 <<MC_CMD_PHY_CAP_25G_BASER_FEC_REQUESTED_LBN ) - : caps & (1 <<MC_CMD_PHY_CAP_BASER_FEC_REQUESTED_LBN ); - -if (!baser && !rs) -return ETHTOOL_FEC_OFF ; -return (rs_req ?ETHTOOL_FEC_RS :0 ) | - (baser_req ?ETHTOOL_FEC_BASER :0 ) | - (baser == baser_req && rs == rs_req ?0 :ETHTOOL_FEC_AUTO ); -} -static int efx_mcdi_phy_probe (struct efx_nic *efx) {struct efx_mcdi_phy_data *phy_data;
drivers/net/ethernet/sfc/mcdi_port_common.c +148 -0
157 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 3/9 sfc: move more MCDI port code
In reply to Alex Maftei (amaftei)Various functions dealing with flow control, forward error correction, polling, port number, and PHY testing.
--- drivers/net/ethernet/sfc/mcdi_port.c | 138 ------------------- drivers/net/ethernet/sfc/mcdi_port_common.c | 139 ++++++++++++++++++++ 2 files changed, 139 insertions(+), 138 deletions(-)
drivers/net/ethernet/sfc/mcdi_port.c +0 -138
@@ -188,58 +188,6 @@ int efx_mcdi_port_reconfigure(struct efx_nic *efx) efx->loopback_mode, 0); } -/* Verify that the forced flow control settings (!EFX_FC_AUTO) are -* supported by the link partner. Warn the user if this isn't the case -*/ -void efx_mcdi_phy_check_fcntl (struct efx_nic *efx,u32 lpa) -{ -struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; -u32 rmtadv; - -/* The link partner capabilities are only relevant if the -* link supports flow control autonegotiation */ -if (~phy_cfg->supported_cap & (1 <<MC_CMD_PHY_CAP_AN_LBN )) -return ; - -/* If flow control autoneg is supported and enabled, then fine */ -if (efx->wanted_fc &EFX_FC_AUTO ) -return ; - - rmtadv =0 ; -if (lpa & (1 <<MC_CMD_PHY_CAP_PAUSE_LBN )) - rmtadv |= ADVERTISED_Pause; -if (lpa & (1 <<MC_CMD_PHY_CAP_ASYM_LBN )) - rmtadv |= ADVERTISED_Asym_Pause; - -if ((efx->wanted_fc &EFX_FC_TX ) && rmtadv == ADVERTISED_Asym_Pause) -netif_err (efx, link, efx->net_dev, -"warning: link partner doesn't support pause frames" ); -} - -bool efx_mcdi_phy_poll (struct efx_nic *efx) -{ -struct efx_link_state old_state = efx->link_state; -MCDI_DECLARE_BUF (outbuf,MC_CMD_GET_LINK_OUT_LEN ); -int rc; - -WARN_ON (!mutex_is_locked (&efx->mac_lock)); - -BUILD_BUG_ON (MC_CMD_GET_LINK_IN_LEN !=0 ); - - rc =efx_mcdi_rpc (efx,MC_CMD_GET_LINK ,NULL ,0 , - outbuf,sizeof (outbuf),NULL ); -if (rc) - efx->link_state.up = false; -else -efx_mcdi_phy_decode_link ( - efx, &efx->link_state, -MCDI_DWORD (outbuf,GET_LINK_OUT_LINK_SPEED ), -MCDI_DWORD (outbuf,GET_LINK_OUT_FLAGS ), -MCDI_DWORD (outbuf,GET_LINK_OUT_FCNTL )); - -return !efx_link_state_equal (&efx->link_state, &old_state); -} -static void efx_mcdi_phy_remove (struct efx_nic *efx) {struct efx_mcdi_phy_data *phy_data = efx->phy_data;
@@ -327,57 +275,6 @@ efx_mcdi_phy_set_link_ksettings(struct efx_nic *efx,return 0 ; } -int efx_mcdi_phy_get_fecparam (struct efx_nic *efx,struct ethtool_fecparam *fec) -{ -MCDI_DECLARE_BUF (outbuf,MC_CMD_GET_LINK_OUT_V2_LEN ); -u32 caps, active, speed;/* MCDI format */ -bool is_25g = false; -size_t outlen; -int rc; - -BUILD_BUG_ON (MC_CMD_GET_LINK_IN_LEN !=0 ); - rc =efx_mcdi_rpc (efx,MC_CMD_GET_LINK ,NULL ,0 , - outbuf,sizeof (outbuf), &outlen); -if (rc) -return rc; -if (outlen <MC_CMD_GET_LINK_OUT_V2_LEN ) -return -EOPNOTSUPP ; - -/* behaviour for 25G/50G links depends on 25G BASER bit */ - speed =MCDI_DWORD (outbuf,GET_LINK_OUT_V2_LINK_SPEED ); - is_25g = speed ==25000 || speed ==50000 ; - - caps =MCDI_DWORD (outbuf,GET_LINK_OUT_V2_CAP ); - fec->fec =mcdi_fec_caps_to_ethtool (caps, is_25g); -/* BASER is never supported on 100G */ -if (speed ==100000 ) - fec->fec &= ~ETHTOOL_FEC_BASER ; - - active =MCDI_DWORD (outbuf,GET_LINK_OUT_V2_FEC_TYPE ); -switch (active) { -case MC_CMD_FEC_NONE : - fec->active_fec =ETHTOOL_FEC_OFF ; -break ; -case MC_CMD_FEC_BASER : - fec->active_fec =ETHTOOL_FEC_BASER ; -break ; -case MC_CMD_FEC_RS : - fec->active_fec =ETHTOOL_FEC_RS ; -break ; -default : -netif_warn (efx, hw, efx->net_dev, -"Firmware reports unrecognised FEC_TYPE %u\n" , - active); -/* We don't know what firmware has picked. AUTO is as good a -* "can't happen" value as any other. -*/ - fec->active_fec =ETHTOOL_FEC_AUTO ; -break ; - } - -return 0 ; -} -static int efx_mcdi_phy_set_fecparam (struct efx_nic *efx,const struct ethtool_fecparam *fec) {
@@ -405,27 +302,6 @@ static int efx_mcdi_phy_set_fecparam(struct efx_nic *efx,return 0 ; } -int efx_mcdi_phy_test_alive (struct efx_nic *efx) -{ -MCDI_DECLARE_BUF (outbuf,MC_CMD_GET_PHY_STATE_OUT_LEN ); -size_t outlen; -int rc; - -BUILD_BUG_ON (MC_CMD_GET_PHY_STATE_IN_LEN !=0 ); - - rc =efx_mcdi_rpc (efx,MC_CMD_GET_PHY_STATE ,NULL ,0 , - outbuf,sizeof (outbuf), &outlen); -if (rc) -return rc; - -if (outlen <MC_CMD_GET_PHY_STATE_OUT_LEN ) -return -EIO ; -if (MCDI_DWORD (outbuf,GET_PHY_STATE_OUT_STATE ) !=MC_CMD_PHY_STATE_OK ) -return -EINVAL ; - -return 0 ; -} -static const char *const mcdi_sft9001_cable_diag_names[] = {"cable.pairA.length" ,"cable.pairB.length" ,
@@ -1008,17 +884,3 @@ void efx_mcdi_port_remove(struct efx_nic *efx) efx->phy_op->remove (efx);efx_nic_free_buffer (efx, &efx->stats_buffer); } - -/* Get physical port number (EF10 only; on Siena it is same as PF number) */ -int efx_mcdi_port_get_number (struct efx_nic *efx) -{ -MCDI_DECLARE_BUF (outbuf,MC_CMD_GET_PORT_ASSIGNMENT_OUT_LEN ); -int rc; - - rc =efx_mcdi_rpc (efx,MC_CMD_GET_PORT_ASSIGNMENT ,NULL ,0 , - outbuf,sizeof (outbuf),NULL ); -if (rc) -return rc; - -return MCDI_DWORD (outbuf,GET_PORT_ASSIGNMENT_OUT_PORT ); -}
drivers/net/ethernet/sfc/mcdi_port_common.c +139 -0
142 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 4/9 sfc: move MCDI VI alloc/free code
In reply to Alex Maftei (amaftei)One function was renamed here, the other contains code extracted from another.
--- drivers/net/ethernet/sfc/Makefile | 2 +- drivers/net/ethernet/sfc/ef10.c | 45 +++-------------- drivers/net/ethernet/sfc/mcdi_functions.c | 61 +++++++++++++++++++++++ 3 files changed, 68 insertions(+), 40 deletions(-) create mode 100644 drivers/net/ethernet/sfc/mcdi_functions.c
drivers/net/ethernet/sfc/Makefile +1 -1
@@ -4,7 +4,7 @@ sfc-y += efx.o efx_common.o efx_channels.o nic.o \ tx.o tx_common.o rx.o rx_common.o \ selftest.o ethtool.o ptp.o tx_tso.o \ mcdi.o mcdi_port.o mcdi_port_common.o \ - mcdi_mon.o + mcdi_functions.o mcdi_mon.o sfc-$(CONFIG_SFC_MTD) += mtd.o sfc-$(CONFIG_SFC_SRIOV) += sriov.o siena_sriov.o ef10_sriov.o
drivers/net/ethernet/sfc/ef10.c +6 -39
83 lines not on this page · raw message
drivers/net/ethernet/sfc/mcdi_functions.c new file +61 -0
61 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 5/9 sfc: move MCDI event queue management code
In reply to Alex Maftei (amaftei)A function was split, the others were renamed.
Code style fixes included.
--- drivers/net/ethernet/sfc/ef10.c | 117 +++------------------- drivers/net/ethernet/sfc/mcdi_functions.c | 103 +++++++++++++++++++ 2 files changed, 116 insertions(+), 104 deletions(-)
drivers/net/ethernet/sfc/ef10.c +13 -104
@@ -3199,106 +3199,20 @@ efx_ef10_rx_defer_refill_complete(struct efx_nic *efx, unsigned long cookie,/* nothing to do */ } -static int efx_ef10_ev_probe (struct efx_channel *channel) -{ -return efx_nic_alloc_buffer (channel->efx, &channel->eventq.buf, - (channel->eventq_mask +1 ) * -sizeof (efx_qword_t), -GFP_KERNEL ); -} - -static void efx_ef10_ev_fini (struct efx_channel *channel) -{ -MCDI_DECLARE_BUF (inbuf,MC_CMD_FINI_EVQ_IN_LEN ); -MCDI_DECLARE_BUF_ERR (outbuf); -struct efx_nic *efx = channel->efx; -size_t outlen; -int rc; - -MCDI_SET_DWORD (inbuf,FINI_EVQ_IN_INSTANCE , channel->channel); - - rc =efx_mcdi_rpc_quiet (efx,MC_CMD_FINI_EVQ , inbuf,sizeof (inbuf), - outbuf,sizeof (outbuf), &outlen); - -if (rc && rc != -EALREADY ) - goto fail; - -return ; - -fail: -efx_mcdi_display_error (efx,MC_CMD_FINI_EVQ ,MC_CMD_FINI_EVQ_IN_LEN , - outbuf, outlen, rc); -} -static int efx_ef10_ev_init (struct efx_channel *channel) { -MCDI_DECLARE_BUF (inbuf, -MC_CMD_INIT_EVQ_V2_IN_LEN (EFX_MAX_EVQ_SIZE *8 / -EFX_BUF_SIZE )); -MCDI_DECLARE_BUF (outbuf,MC_CMD_INIT_EVQ_V2_OUT_LEN ); -size_t entries = channel->eventq.buf.len /EFX_BUF_SIZE ;struct efx_nic *efx = channel->efx;struct efx_ef10_nic_data *nic_data; -size_t inlen, outlen;unsigned int enabled, implemented; -dma_addr_t dma_addr; +bool use_v2, cut_thru;int rc; -int i; nic_data = efx->nic_data; - -/* Fill event queue with all ones (i.e. empty events) */ -memset (channel->eventq.buf.addr,0xff , channel->eventq.buf.len); - -MCDI_SET_DWORD (inbuf,INIT_EVQ_IN_SIZE , channel->eventq_mask +1 ); -MCDI_SET_DWORD (inbuf,INIT_EVQ_IN_INSTANCE , channel->channel); -/* INIT_EVQ expects index in vector table, not absolute */ -MCDI_SET_DWORD (inbuf,INIT_EVQ_IN_IRQ_NUM , channel->channel); -MCDI_SET_DWORD (inbuf,INIT_EVQ_IN_TMR_MODE , -MC_CMD_INIT_EVQ_IN_TMR_MODE_DIS ); -MCDI_SET_DWORD (inbuf,INIT_EVQ_IN_TMR_LOAD ,0 ); -MCDI_SET_DWORD (inbuf,INIT_EVQ_IN_TMR_RELOAD ,0 ); -MCDI_SET_DWORD (inbuf,INIT_EVQ_IN_COUNT_MODE , -MC_CMD_INIT_EVQ_IN_COUNT_MODE_DIS ); -MCDI_SET_DWORD (inbuf,INIT_EVQ_IN_COUNT_THRSHLD ,0 ); - -if (nic_data->datapath_caps2 & -1 <<MC_CMD_GET_CAPABILITIES_V2_OUT_INIT_EVQ_V2_LBN ) { -/* Use the new generic approach to specifying event queue -* configuration, requesting lower latency or higher throughput. -* The options that actually get used appear in the output. -*/ -MCDI_POPULATE_DWORD_2 (inbuf,INIT_EVQ_V2_IN_FLAGS , -INIT_EVQ_V2_IN_FLAG_INTERRUPTING ,1 , -INIT_EVQ_V2_IN_FLAG_TYPE , -MC_CMD_INIT_EVQ_V2_IN_FLAG_TYPE_AUTO ); - }else { -bool cut_thru = !(nic_data->datapath_caps & -1 <<MC_CMD_GET_CAPABILITIES_OUT_RX_BATCHING_LBN ); - -MCDI_POPULATE_DWORD_4 (inbuf,INIT_EVQ_IN_FLAGS , -INIT_EVQ_IN_FLAG_INTERRUPTING ,1 , -INIT_EVQ_IN_FLAG_RX_MERGE ,1 , -INIT_EVQ_IN_FLAG_TX_MERGE ,1 , -INIT_EVQ_IN_FLAG_CUT_THRU , cut_thru); - } - - dma_addr = channel->eventq.buf.dma_addr; -for (i =0 ; i < entries; ++i) { -MCDI_SET_ARRAY_QWORD (inbuf,INIT_EVQ_IN_DMA_ADDR , i, dma_addr); - dma_addr +=EFX_BUF_SIZE ; - } - - inlen =MC_CMD_INIT_EVQ_IN_LEN (entries); - - rc =efx_mcdi_rpc (efx,MC_CMD_INIT_EVQ , inbuf, inlen, - outbuf,sizeof (outbuf), &outlen); - -if (outlen >=MC_CMD_INIT_EVQ_V2_OUT_LEN ) -netif_dbg (efx, drv, efx->net_dev, -"Channel %d using event queue flags %08x\n" , - channel->channel, -MCDI_DWORD (outbuf,INIT_EVQ_V2_OUT_FLAGS )); + use_v2 = nic_data->datapath_caps2 & +1 <<MC_CMD_GET_CAPABILITIES_V2_OUT_INIT_EVQ_V2_LBN ; + cut_thru = !(nic_data->datapath_caps & +1 <<MC_CMD_GET_CAPABILITIES_OUT_RX_BATCHING_LBN ); + rc =efx_mcdi_ev_init (channel, cut_thru, use_v2);/* IRQ return is ignored */ if (channel->channel || rc)
@@ -3356,15 +3270,10 @@ static int efx_ef10_ev_init(struct efx_channel *channel)return 0 ; fail: -efx_ef10_ev_fini (channel); +efx_mcdi_ev_fini (channel);return rc; } -static void efx_ef10_ev_remove (struct efx_channel *channel) -{ -efx_nic_free_buffer (channel->efx, &channel->eventq.buf); -} -static void efx_ef10_handle_rx_wrong_queue (struct efx_rx_queue *rx_queue,unsigned int rx_queue_label) {
@@ -6630,10 +6539,10 @@ const struct efx_nic_type efx_hunt_a0_vf_nic_type = { .rx_remove = efx_ef10_rx_remove, .rx_write = efx_ef10_rx_write, .rx_defer_refill = efx_ef10_rx_defer_refill, - .ev_probe = efx_ef10_ev_probe, + .ev_probe = efx_mcdi_ev_probe, .ev_init = efx_ef10_ev_init, - .ev_fini = efx_ef10_ev_fini, - .ev_remove = efx_ef10_ev_remove, + .ev_fini = efx_mcdi_ev_fini, + .ev_remove = efx_mcdi_ev_remove, .ev_process = efx_ef10_ev_process, .ev_read_ack = efx_ef10_ev_read_ack, .ev_test_generate = efx_ef10_ev_test_generate,
@@ -6742,10 +6651,10 @@ const struct efx_nic_type efx_hunt_a0_nic_type = { .rx_remove = efx_ef10_rx_remove, .rx_write = efx_ef10_rx_write, .rx_defer_refill = efx_ef10_rx_defer_refill, - .ev_probe = efx_ef10_ev_probe, + .ev_probe = efx_mcdi_ev_probe, .ev_init = efx_ef10_ev_init, - .ev_fini = efx_ef10_ev_fini, - .ev_remove = efx_ef10_ev_remove, + .ev_fini = efx_mcdi_ev_fini, + .ev_remove = efx_mcdi_ev_remove, .ev_process = efx_ef10_ev_process, .ev_read_ack = efx_ef10_ev_read_ack, .ev_test_generate = efx_ef10_ev_test_generate,
drivers/net/ethernet/sfc/mcdi_functions.c +103 -0
106 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 6/9 sfc: move MCDI transmit queue management code
In reply to Alex Maftei (amaftei)A function was split, the others were renamed.
Code style fixes included.
--- drivers/net/ethernet/sfc/ef10.c | 94 ++------------------ drivers/net/ethernet/sfc/mcdi_functions.c | 100 ++++++++++++++++++++++ 2 files changed, 109 insertions(+), 85 deletions(-)
drivers/net/ethernet/sfc/ef10.c +9 -85
@@ -2378,20 +2378,15 @@ static u32 efx_ef10_tso_versions(struct efx_nic *efx)static void efx_ef10_tx_init (struct efx_tx_queue *tx_queue) { -MCDI_DECLARE_BUF (inbuf,MC_CMD_INIT_TXQ_IN_LEN (EFX_MAX_DMAQ_SIZE *8 / -EFX_BUF_SIZE ));bool csum_offload = tx_queue->queue &EFX_TXQ_TYPE_OFFLOAD ; -size_t entries = tx_queue->txd.buf.len /EFX_BUF_SIZE ;struct efx_channel *channel = tx_queue->channel;struct efx_nic *efx = tx_queue->efx; -struct efx_ef10_nic_data *nic_data = efx->nic_data; +struct efx_ef10_nic_data *nic_data;bool tso_v2 = false; -size_t inlen; -dma_addr_t dma_addr;efx_qword_t *txd;int rc; -int i; -BUILD_BUG_ON (MC_CMD_INIT_TXQ_OUT_LEN !=0 ); + + nic_data = efx->nic_data;/* Only attempt to enable TX timestamping if we have the license for it, * otherwise TXQ init will fail
@@ -2418,51 +2413,9 @@ static void efx_ef10_tx_init(struct efx_tx_queue *tx_queue) channel->channel); } -MCDI_SET_DWORD (inbuf,INIT_TXQ_IN_SIZE , tx_queue->ptr_mask +1 ); -MCDI_SET_DWORD (inbuf,INIT_TXQ_IN_TARGET_EVQ , channel->channel); -MCDI_SET_DWORD (inbuf,INIT_TXQ_IN_LABEL , tx_queue->queue); -MCDI_SET_DWORD (inbuf,INIT_TXQ_IN_INSTANCE , tx_queue->queue); -MCDI_SET_DWORD (inbuf,INIT_TXQ_IN_OWNER_ID ,0 ); -MCDI_SET_DWORD (inbuf,INIT_TXQ_IN_PORT_ID , nic_data->vport_id); - - dma_addr = tx_queue->txd.buf.dma_addr; - -netif_dbg (efx, hw, efx->net_dev,"pushing TXQ %d. %zu entries (%llx)\n" , - tx_queue->queue, entries, (u64 )dma_addr); - -for (i =0 ; i < entries; ++i) { -MCDI_SET_ARRAY_QWORD (inbuf,INIT_TXQ_IN_DMA_ADDR , i, dma_addr); - dma_addr +=EFX_BUF_SIZE ; - } - - inlen =MC_CMD_INIT_TXQ_IN_LEN (entries); - -do { -MCDI_POPULATE_DWORD_4 (inbuf,INIT_TXQ_IN_FLAGS , -/* This flag was removed from mcdi_pcol.h for -* the non-_EXT version of INIT_TXQ. However, -* firmware still honours it. -*/ -INIT_TXQ_EXT_IN_FLAG_TSOV2_EN , tso_v2, -INIT_TXQ_IN_FLAG_IP_CSUM_DIS , !csum_offload, -INIT_TXQ_IN_FLAG_TCP_CSUM_DIS , !csum_offload, -INIT_TXQ_EXT_IN_FLAG_TIMESTAMP , - tx_queue->timestamping); - - rc =efx_mcdi_rpc_quiet (efx,MC_CMD_INIT_TXQ , inbuf, inlen, -NULL ,0 ,NULL ); -if (rc == -ENOSPC && tso_v2) { -/* Retry without TSOv2 if we're short on contexts. */ - tso_v2 = false; -netif_warn (efx, probe, efx->net_dev, -"TSOv2 context not available to segment in hardware. TCP performance may be reduced.\n" ); - }else if (rc) { -efx_mcdi_display_error (efx,MC_CMD_INIT_TXQ , -MC_CMD_INIT_TXQ_EXT_IN_LEN , -NULL ,0 , rc); - goto fail; - } - }while (rc); + rc =efx_mcdi_tx_init (tx_queue, tso_v2); +if (rc) + goto fail;/* A previous user of this TX queue might have set us up the * bomb by writing a descriptor to the TX push collector but
@@ -2500,35 +2453,6 @@ static void efx_ef10_tx_init(struct efx_tx_queue *tx_queue) tx_queue->queue); } -static void efx_ef10_tx_fini (struct efx_tx_queue *tx_queue) -{ -MCDI_DECLARE_BUF (inbuf,MC_CMD_FINI_TXQ_IN_LEN ); -MCDI_DECLARE_BUF_ERR (outbuf); -struct efx_nic *efx = tx_queue->efx; -size_t outlen; -int rc; - -MCDI_SET_DWORD (inbuf,FINI_TXQ_IN_INSTANCE , - tx_queue->queue); - - rc =efx_mcdi_rpc_quiet (efx,MC_CMD_FINI_TXQ , inbuf,sizeof (inbuf), - outbuf,sizeof (outbuf), &outlen); - -if (rc && rc != -EALREADY ) - goto fail; - -return ; - -fail: -efx_mcdi_display_error (efx,MC_CMD_FINI_TXQ ,MC_CMD_FINI_TXQ_IN_LEN , - outbuf, outlen, rc); -} - -static void efx_ef10_tx_remove (struct efx_tx_queue *tx_queue) -{ -efx_nic_free_buffer (tx_queue->efx, &tx_queue->txd.buf); -} -/* This writes to the TX_DESC_WPTR; write pointer for TX descriptor ring */ static inline void efx_ef10_notify_tx_desc (struct efx_tx_queue *tx_queue) {
@@ -3857,7 +3781,7 @@ static int efx_ef10_fini_dmaq(struct efx_nic *efx)efx_for_each_channel_rx_queue (rx_queue, channel)efx_ef10_rx_fini (rx_queue);efx_for_each_channel_tx_queue (tx_queue, channel) -efx_ef10_tx_fini (tx_queue); +efx_mcdi_tx_fini (tx_queue); } wait_event_timeout(efx->flush_wq,
@@ -6529,7 +6453,7 @@ const struct efx_nic_type efx_hunt_a0_vf_nic_type = { .irq_handle_legacy = efx_ef10_legacy_interrupt, .tx_probe = efx_ef10_tx_probe, .tx_init = efx_ef10_tx_init, - .tx_remove = efx_ef10_tx_remove, + .tx_remove = efx_mcdi_tx_remove, .tx_write = efx_ef10_tx_write, .tx_limit_len = efx_ef10_tx_limit_len, .rx_push_rss_config = efx_ef10_vf_rx_push_rss_config,
@@ -6638,7 +6562,7 @@ const struct efx_nic_type efx_hunt_a0_nic_type = { .irq_handle_legacy = efx_ef10_legacy_interrupt, .tx_probe = efx_ef10_tx_probe, .tx_init = efx_ef10_tx_init, - .tx_remove = efx_ef10_tx_remove, + .tx_remove = efx_mcdi_tx_remove, .tx_write = efx_ef10_tx_write, .tx_limit_len = efx_ef10_tx_limit_len, .rx_push_rss_config = efx_ef10_pf_rx_push_rss_config,
drivers/net/ethernet/sfc/mcdi_functions.c +100 -0
103 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 7/9 sfc: move MCDI receive queue management code
In reply to Alex Maftei (amaftei)One function's prototype was changed in the header.
--- drivers/net/ethernet/sfc/ef10.c | 99 ++--------------------- drivers/net/ethernet/sfc/mcdi_functions.c | 85 +++++++++++++++++++ drivers/net/ethernet/sfc/mcdi_functions.h | 2 +- 3 files changed, 93 insertions(+), 93 deletions(-)
drivers/net/ethernet/sfc/ef10.c +7 -92
@@ -2967,91 +2967,6 @@ static int efx_ef10_vf_rx_push_rss_config(struct efx_nic *efx, bool user,return efx_ef10_rx_push_shared_rss_config (efx,NULL ); } -static int efx_ef10_rx_probe (struct efx_rx_queue *rx_queue) -{ -return efx_nic_alloc_buffer (rx_queue->efx, &rx_queue->rxd.buf, - (rx_queue->ptr_mask +1 ) * -sizeof (efx_qword_t), -GFP_KERNEL ); -} - -static void efx_ef10_rx_init (struct efx_rx_queue *rx_queue) -{ -MCDI_DECLARE_BUF (inbuf, -MC_CMD_INIT_RXQ_IN_LEN (EFX_MAX_DMAQ_SIZE *8 / -EFX_BUF_SIZE )); -struct efx_channel *channel =efx_rx_queue_channel (rx_queue); -size_t entries = rx_queue->rxd.buf.len /EFX_BUF_SIZE ; -struct efx_nic *efx = rx_queue->efx; -struct efx_ef10_nic_data *nic_data = efx->nic_data; -size_t inlen; -dma_addr_t dma_addr; -int rc; -int i; -BUILD_BUG_ON (MC_CMD_INIT_RXQ_OUT_LEN !=0 ); - - rx_queue->scatter_n =0 ; - rx_queue->scatter_len =0 ; - -MCDI_SET_DWORD (inbuf,INIT_RXQ_IN_SIZE , rx_queue->ptr_mask +1 ); -MCDI_SET_DWORD (inbuf,INIT_RXQ_IN_TARGET_EVQ , channel->channel); -MCDI_SET_DWORD (inbuf,INIT_RXQ_IN_LABEL ,efx_rx_queue_index (rx_queue)); -MCDI_SET_DWORD (inbuf,INIT_RXQ_IN_INSTANCE , -efx_rx_queue_index (rx_queue)); -MCDI_POPULATE_DWORD_2 (inbuf,INIT_RXQ_IN_FLAGS , -INIT_RXQ_IN_FLAG_PREFIX ,1 , -INIT_RXQ_IN_FLAG_TIMESTAMP ,1 ); -MCDI_SET_DWORD (inbuf,INIT_RXQ_IN_OWNER_ID ,0 ); -MCDI_SET_DWORD (inbuf,INIT_RXQ_IN_PORT_ID , nic_data->vport_id); - - dma_addr = rx_queue->rxd.buf.dma_addr; - -netif_dbg (efx, hw, efx->net_dev,"pushing RXQ %d. %zu entries (%llx)\n" , -efx_rx_queue_index (rx_queue), entries, (u64 )dma_addr); - -for (i =0 ; i < entries; ++i) { -MCDI_SET_ARRAY_QWORD (inbuf,INIT_RXQ_IN_DMA_ADDR , i, dma_addr); - dma_addr +=EFX_BUF_SIZE ; - } - - inlen =MC_CMD_INIT_RXQ_IN_LEN (entries); - - rc =efx_mcdi_rpc (efx,MC_CMD_INIT_RXQ , inbuf, inlen, -NULL ,0 ,NULL ); -if (rc) -netdev_WARN (efx->net_dev,"failed to initialise RXQ %d\n" , -efx_rx_queue_index (rx_queue)); -} - -static void efx_ef10_rx_fini (struct efx_rx_queue *rx_queue) -{ -MCDI_DECLARE_BUF (inbuf,MC_CMD_FINI_RXQ_IN_LEN ); -MCDI_DECLARE_BUF_ERR (outbuf); -struct efx_nic *efx = rx_queue->efx; -size_t outlen; -int rc; - -MCDI_SET_DWORD (inbuf,FINI_RXQ_IN_INSTANCE , -efx_rx_queue_index (rx_queue)); - - rc =efx_mcdi_rpc_quiet (efx,MC_CMD_FINI_RXQ , inbuf,sizeof (inbuf), - outbuf,sizeof (outbuf), &outlen); - -if (rc && rc != -EALREADY ) - goto fail; - -return ; - -fail: -efx_mcdi_display_error (efx,MC_CMD_FINI_RXQ ,MC_CMD_FINI_RXQ_IN_LEN , - outbuf, outlen, rc); -} - -static void efx_ef10_rx_remove (struct efx_rx_queue *rx_queue) -{ -efx_nic_free_buffer (rx_queue->efx, &rx_queue->rxd.buf); -} -/* This creates an entry in the RX descriptor queue */ static inline void efx_ef10_build_rx_desc (struct efx_rx_queue *rx_queue,unsigned int index)
@@ -3779,7 +3694,7 @@ static int efx_ef10_fini_dmaq(struct efx_nic *efx)if (efx->state !=STATE_RECOVERY ) {efx_for_each_channel (channel, efx) {efx_for_each_channel_rx_queue (rx_queue, channel) -efx_ef10_rx_fini (rx_queue); +efx_mcdi_rx_fini (rx_queue);efx_for_each_channel_tx_queue (tx_queue, channel)efx_mcdi_tx_fini (tx_queue); }
@@ -6458,9 +6373,9 @@ const struct efx_nic_type efx_hunt_a0_vf_nic_type = { .tx_limit_len = efx_ef10_tx_limit_len, .rx_push_rss_config = efx_ef10_vf_rx_push_rss_config, .rx_pull_rss_config = efx_ef10_rx_pull_rss_config, - .rx_probe = efx_ef10_rx_probe, - .rx_init = efx_ef10_rx_init, - .rx_remove = efx_ef10_rx_remove, + .rx_probe = efx_mcdi_rx_probe, + .rx_init = efx_mcdi_rx_init, + .rx_remove = efx_mcdi_rx_remove, .rx_write = efx_ef10_rx_write, .rx_defer_refill = efx_ef10_rx_defer_refill, .ev_probe = efx_mcdi_ev_probe,
@@ -6570,9 +6485,9 @@ const struct efx_nic_type efx_hunt_a0_nic_type = { .rx_push_rss_context_config = efx_ef10_rx_push_rss_context_config, .rx_pull_rss_context_config = efx_ef10_rx_pull_rss_context_config, .rx_restore_rss_contexts = efx_ef10_rx_restore_rss_contexts, - .rx_probe = efx_ef10_rx_probe, - .rx_init = efx_ef10_rx_init, - .rx_remove = efx_ef10_rx_remove, + .rx_probe = efx_mcdi_rx_probe, + .rx_init = efx_mcdi_rx_init, + .rx_remove = efx_mcdi_rx_remove, .rx_write = efx_ef10_rx_write, .rx_defer_refill = efx_ef10_rx_defer_refill, .ev_probe = efx_mcdi_ev_probe,
drivers/net/ethernet/sfc/mcdi_functions.c +85 -0
88 lines not on this page · raw message
drivers/net/ethernet/sfc/mcdi_functions.h +1 -1
@@ -23,7 +23,7 @@ int efx_mcdi_tx_init(struct efx_tx_queue *tx_queue, bool tso_v2);void efx_mcdi_tx_remove (struct efx_tx_queue *tx_queue);void efx_mcdi_tx_fini (struct efx_tx_queue *tx_queue);int efx_mcdi_rx_probe (struct efx_rx_queue *rx_queue); -int efx_mcdi_rx_init (struct efx_rx_queue *rx_queue,bool want_outer_classes); +void efx_mcdi_rx_init (struct efx_rx_queue *rx_queue);void efx_mcdi_rx_remove (struct efx_rx_queue *rx_queue);void efx_mcdi_rx_fini (struct efx_rx_queue *rx_queue);
Signature · 1 line
2.20.1
PATCH 8/9 sfc: conditioned some functionality
In reply to Alex Maftei (amaftei)Before calling certain function pointers, check that they are non-NULL.
--- drivers/net/ethernet/sfc/efx_channels.c | 6 ++-- drivers/net/ethernet/sfc/efx_common.c | 47 +++++++++++++++---------- 2 files changed, 32 insertions(+), 21 deletions(-)
drivers/net/ethernet/sfc/efx_channels.c +4 -2
@@ -1039,7 +1039,7 @@ void efx_stop_channels(struct efx_nic *efx)struct efx_tx_queue *tx_queue;struct efx_rx_queue *rx_queue;struct efx_channel *channel; -int rc; +int rc =0 ;/* Stop RX refill */ efx_for_each_channel (channel, efx) {
@@ -1060,7 +1060,9 @@ void efx_stop_channels(struct efx_nic *efx) } } - rc = efx->type->fini_dmaq (efx); +if (efx->type->fini_dmaq) + rc = efx->type->fini_dmaq (efx); +if (rc) {netif_err (efx, drv, efx->net_dev,"failed to flush queues\n" ); }else {
drivers/net/ethernet/sfc/efx_common.c +28 -19
83 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 9/9 sfc: move MCDI logging device attribute
In reply to Alex Maftei (amaftei)A few bits were extracted from other functions.
--- drivers/net/ethernet/sfc/efx.c | 40 ++------------------------- drivers/net/ethernet/sfc/efx_common.c | 39 ++++++++++++++++++++++++++ drivers/net/ethernet/sfc/efx_common.h | 8 ++++++ 3 files changed, 50 insertions(+), 37 deletions(-)
drivers/net/ethernet/sfc/efx.c +3 -37
@@ -1036,28 +1036,6 @@ show_phy_type(struct device *dev, struct device_attribute *attr, char *buf) } static DEVICE_ATTR(phy_type, 0444, show_phy_type, NULL); -#ifdef CONFIG_SFC_MCDI_LOGGING -static ssize_t show_mcdi_log (struct device *dev,struct device_attribute *attr, -char *buf) -{ -struct efx_nic *efx =dev_get_drvdata (dev); -struct efx_mcdi_iface *mcdi =efx_mcdi (efx); - -return scnprintf (buf,PAGE_SIZE ,"%d\n" , mcdi->logging_enabled); -} -static ssize_t set_mcdi_log (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) -{ -struct efx_nic *efx =dev_get_drvdata (dev); -struct efx_mcdi_iface *mcdi =efx_mcdi (efx); -bool enable = count >0 && *buf !='0' ; - - mcdi->logging_enabled = enable; -return count; -} -static DEVICE_ATTR(mcdi_logging, 0644, show_mcdi_log, set_mcdi_log); -#endif -static int efx_register_netdev (struct efx_nic *efx) {struct net_device *net_dev = efx->net_dev;
@@ -1117,21 +1095,11 @@ static int efx_register_netdev(struct efx_nic *efx) "failed to init net dev attributes\n"); goto fail_registered; } -#ifdef CONFIG_SFC_MCDI_LOGGING - rc =device_create_file (&efx->pci_dev->dev, &dev_attr_mcdi_logging); -if (rc) { -netif_err (efx, drv, efx->net_dev, -"failed to init net dev attributes\n" ); - goto fail_attr_mcdi_logging; - } -#endif + +efx_init_mcdi_logging (efx);return 0 ; -#ifdef CONFIG_SFC_MCDI_LOGGING -fail_attr_mcdi_logging: -device_remove_file (&efx->pci_dev->dev, &dev_attr_phy_type); -#endif fail_registered:rtnl_lock ();efx_dissociate (efx);
@@ -1152,9 +1120,7 @@ static void efx_unregister_netdev(struct efx_nic *efx)if (efx_dev_registered (efx)) {strlcpy (efx->name,pci_name (efx->pci_dev),sizeof (efx->name)); -#ifdef CONFIG_SFC_MCDI_LOGGING -device_remove_file (&efx->pci_dev->dev, &dev_attr_mcdi_logging); -#endif +efx_fini_mcdi_logging (efx);device_remove_file (&efx->pci_dev->dev, &dev_attr_phy_type);unregister_netdev (efx->net_dev); }
drivers/net/ethernet/sfc/efx_common.c +39 -0
@@ -1006,3 +1006,42 @@ void efx_fini_io(struct efx_nic *efx, int bar)if (!pci_vfs_assigned (efx->pci_dev))pci_disable_device (efx->pci_dev); } + +#ifdef CONFIG_SFC_MCDI_LOGGING +static ssize_t show_mcdi_log (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct efx_nic *efx =dev_get_drvdata (dev); +struct efx_mcdi_iface *mcdi =efx_mcdi (efx); + +return scnprintf (buf,PAGE_SIZE ,"%d\n" , mcdi->logging_enabled); +} + +static ssize_t set_mcdi_log (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) +{ +struct efx_nic *efx =dev_get_drvdata (dev); +struct efx_mcdi_iface *mcdi =efx_mcdi (efx); +bool enable = count >0 && *buf !='0' ; + + mcdi->logging_enabled = enable; +return count; +} + +static DEVICE_ATTR(mcdi_logging, 0644, show_mcdi_log, set_mcdi_log); + +void efx_init_mcdi_logging (struct efx_nic *efx) +{ +int rc =device_create_file (&efx->pci_dev->dev, &dev_attr_mcdi_logging); + +if (rc) { +netif_warn (efx, drv, efx->net_dev, +"failed to init net dev attributes\n" ); + } +} + +void efx_fini_mcdi_logging (struct efx_nic *efx) +{ +device_remove_file (&efx->pci_dev->dev, &dev_attr_mcdi_logging); +} +#endif
drivers/net/ethernet/sfc/efx_common.h +8 -0
@@ -55,6 +55,14 @@ static inline int efx_check_disabled(struct efx_nic *efx)return 0 ; } +#ifdef CONFIG_SFC_MCDI_LOGGING +void efx_init_mcdi_logging (struct efx_nic *efx); +void efx_fini_mcdi_logging (struct efx_nic *efx); +#else +static inline void efx_init_mcdi_logging (struct efx_nic *efx) {} +static inline void efx_fini_mcdi_logging (struct efx_nic *efx) {} +#endif +void efx_mac_reconfigure (struct efx_nic *efx);void efx_link_status_changed (struct efx_nic *efx);
Signature · 1 line
2.20.1
David Miller
maintainerFrom: "Alex Maftei (amaftei)" <[email protected]>
Date: Thu, 9 Jan 2020 15:41:43 +0000
Quoted 9 lines
Splitting more of the driver code into different files, which will later be used in another driver for a new product.
This is a continuation to my previous patch series. There will be another series and a stand-alone patch as well after this.
This series in particular covers MCDI (management controller driver interface) code.
Series applied, thanks.