Commit b1daa4d1 authored by David S. Miller's avatar David S. Miller

Merge branch 'sfc-more-code-refactoring'

Alex Maftei says:

====================
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.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 43ad352d b69f7a3e
...@@ -3,8 +3,8 @@ sfc-y += efx.o efx_common.o efx_channels.o nic.o \ ...@@ -3,8 +3,8 @@ sfc-y += efx.o efx_common.o efx_channels.o nic.o \
farch.o siena.o ef10.o \ farch.o siena.o ef10.o \
tx.o tx_common.o rx.o rx_common.o \ tx.o tx_common.o rx.o rx_common.o \
selftest.o ethtool.o ptp.o tx_tso.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 mcdi_functions.o mcdi_mon.o
sfc-$(CONFIG_SFC_MTD) += mtd.o sfc-$(CONFIG_SFC_MTD) += mtd.o
sfc-$(CONFIG_SFC_SRIOV) += sriov.o siena_sriov.o ef10_sriov.o sfc-$(CONFIG_SFC_SRIOV) += sriov.o siena_sriov.o ef10_sriov.o
......
This diff is collapsed.
...@@ -134,21 +134,6 @@ static int efx_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **xdpfs, ...@@ -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 /* Equivalent to efx_link_set_advertising with all-zeroes, except does not
* force the Autoneg bit on. * force the Autoneg bit on.
*/ */
...@@ -1051,28 +1036,6 @@ show_phy_type(struct device *dev, struct device_attribute *attr, char *buf) ...@@ -1051,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); 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) static int efx_register_netdev(struct efx_nic *efx)
{ {
struct net_device *net_dev = efx->net_dev; struct net_device *net_dev = efx->net_dev;
...@@ -1132,21 +1095,11 @@ static int efx_register_netdev(struct efx_nic *efx) ...@@ -1132,21 +1095,11 @@ static int efx_register_netdev(struct efx_nic *efx)
"failed to init net dev attributes\n"); "failed to init net dev attributes\n");
goto fail_registered; goto fail_registered;
} }
#ifdef CONFIG_SFC_MCDI_LOGGING
rc = device_create_file(&efx->pci_dev->dev, &dev_attr_mcdi_logging); efx_init_mcdi_logging(efx);
if (rc) {
netif_err(efx, drv, efx->net_dev,
"failed to init net dev attributes\n");
goto fail_attr_mcdi_logging;
}
#endif
return 0; 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: fail_registered:
rtnl_lock(); rtnl_lock();
efx_dissociate(efx); efx_dissociate(efx);
...@@ -1167,9 +1120,7 @@ static void efx_unregister_netdev(struct efx_nic *efx) ...@@ -1167,9 +1120,7 @@ static void efx_unregister_netdev(struct efx_nic *efx)
if (efx_dev_registered(efx)) { if (efx_dev_registered(efx)) {
strlcpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name)); strlcpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name));
#ifdef CONFIG_SFC_MCDI_LOGGING efx_fini_mcdi_logging(efx);
device_remove_file(&efx->pci_dev->dev, &dev_attr_mcdi_logging);
#endif
device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_type); device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_type);
unregister_netdev(efx->net_dev); unregister_netdev(efx->net_dev);
} }
......
...@@ -1039,7 +1039,7 @@ void efx_stop_channels(struct efx_nic *efx) ...@@ -1039,7 +1039,7 @@ void efx_stop_channels(struct efx_nic *efx)
struct efx_tx_queue *tx_queue; struct efx_tx_queue *tx_queue;
struct efx_rx_queue *rx_queue; struct efx_rx_queue *rx_queue;
struct efx_channel *channel; struct efx_channel *channel;
int rc; int rc = 0;
/* Stop RX refill */ /* Stop RX refill */
efx_for_each_channel(channel, efx) { efx_for_each_channel(channel, efx) {
...@@ -1060,7 +1060,9 @@ void efx_stop_channels(struct efx_nic *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) { if (rc) {
netif_err(efx, drv, efx->net_dev, "failed to flush queues\n"); netif_err(efx, drv, efx->net_dev, "failed to flush queues\n");
} else { } else {
......
...@@ -141,9 +141,11 @@ void efx_destroy_reset_workqueue(void) ...@@ -141,9 +141,11 @@ void efx_destroy_reset_workqueue(void)
*/ */
void efx_mac_reconfigure(struct efx_nic *efx) void efx_mac_reconfigure(struct efx_nic *efx)
{ {
down_read(&efx->filter_sem); if (efx->type->reconfigure_mac) {
efx->type->reconfigure_mac(efx); down_read(&efx->filter_sem);
up_read(&efx->filter_sem); efx->type->reconfigure_mac(efx);
up_read(&efx->filter_sem);
}
} }
/* Asynchronous work item for changing MAC promiscuity and multicast /* Asynchronous work item for changing MAC promiscuity and multicast
...@@ -296,7 +298,8 @@ static void efx_start_datapath(struct efx_nic *efx) ...@@ -296,7 +298,8 @@ static void efx_start_datapath(struct efx_nic *efx)
netdev_features_change(efx->net_dev); netdev_features_change(efx->net_dev);
/* RX filters may also have scatter-enabled flags */ /* RX filters may also have scatter-enabled flags */
if (efx->rx_scatter != old_rx_scatter) if ((efx->rx_scatter != old_rx_scatter) &&
efx->type->filter_update_rx_scatter)
efx->type->filter_update_rx_scatter(efx); efx->type->filter_update_rx_scatter(efx);
/* We must keep at least one descriptor in a TX ring empty. /* We must keep at least one descriptor in a TX ring empty.
...@@ -405,11 +408,13 @@ void efx_start_all(struct efx_nic *efx) ...@@ -405,11 +408,13 @@ void efx_start_all(struct efx_nic *efx)
efx_link_status_changed(efx); efx_link_status_changed(efx);
mutex_unlock(&efx->mac_lock); mutex_unlock(&efx->mac_lock);
efx->type->start_stats(efx); if (efx->type->start_stats) {
efx->type->pull_stats(efx); efx->type->start_stats(efx);
spin_lock_bh(&efx->stats_lock); efx->type->pull_stats(efx);
efx->type->update_stats(efx, NULL, NULL); spin_lock_bh(&efx->stats_lock);
spin_unlock_bh(&efx->stats_lock); efx->type->update_stats(efx, NULL, NULL);
spin_unlock_bh(&efx->stats_lock);
}
} }
/* Quiesce the hardware and software data path, and regular activity /* Quiesce the hardware and software data path, and regular activity
...@@ -425,14 +430,17 @@ void efx_stop_all(struct efx_nic *efx) ...@@ -425,14 +430,17 @@ void efx_stop_all(struct efx_nic *efx)
if (!efx->port_enabled) if (!efx->port_enabled)
return; return;
/* update stats before we go down so we can accurately count if (efx->type->update_stats) {
* rx_nodesc_drops /* update stats before we go down so we can accurately count
*/ * rx_nodesc_drops
efx->type->pull_stats(efx); */
spin_lock_bh(&efx->stats_lock); efx->type->pull_stats(efx);
efx->type->update_stats(efx, NULL, NULL); spin_lock_bh(&efx->stats_lock);
spin_unlock_bh(&efx->stats_lock); efx->type->update_stats(efx, NULL, NULL);
efx->type->stop_stats(efx); spin_unlock_bh(&efx->stats_lock);
efx->type->stop_stats(efx);
}
efx_stop_port(efx); efx_stop_port(efx);
/* Stop the kernel transmit interface. This is only valid if /* Stop the kernel transmit interface. This is only valid if
...@@ -456,7 +464,7 @@ void efx_stop_all(struct efx_nic *efx) ...@@ -456,7 +464,7 @@ void efx_stop_all(struct efx_nic *efx)
int __efx_reconfigure_port(struct efx_nic *efx) int __efx_reconfigure_port(struct efx_nic *efx)
{ {
enum efx_phy_mode phy_mode; enum efx_phy_mode phy_mode;
int rc; int rc = 0;
WARN_ON(!mutex_is_locked(&efx->mac_lock)); WARN_ON(!mutex_is_locked(&efx->mac_lock));
...@@ -467,7 +475,8 @@ int __efx_reconfigure_port(struct efx_nic *efx) ...@@ -467,7 +475,8 @@ int __efx_reconfigure_port(struct efx_nic *efx)
else else
efx->phy_mode &= ~PHY_MODE_TX_DISABLED; efx->phy_mode &= ~PHY_MODE_TX_DISABLED;
rc = efx->type->reconfigure_port(efx); if (efx->type->reconfigure_port)
rc = efx->type->reconfigure_port(efx);
if (rc) if (rc)
efx->phy_mode = phy_mode; efx->phy_mode = phy_mode;
...@@ -997,3 +1006,42 @@ void efx_fini_io(struct efx_nic *efx, int bar) ...@@ -997,3 +1006,42 @@ void efx_fini_io(struct efx_nic *efx, int bar)
if (!pci_vfs_assigned(efx->pci_dev)) if (!pci_vfs_assigned(efx->pci_dev))
pci_disable_device(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
...@@ -55,6 +55,14 @@ static inline int efx_check_disabled(struct efx_nic *efx) ...@@ -55,6 +55,14 @@ static inline int efx_check_disabled(struct efx_nic *efx)
return 0; 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_mac_reconfigure(struct efx_nic *efx);
void efx_link_status_changed(struct efx_nic *efx); void efx_link_status_changed(struct efx_nic *efx);
......
This diff is collapsed.
...@@ -23,7 +23,7 @@ int efx_mcdi_tx_init(struct efx_tx_queue *tx_queue, bool tso_v2); ...@@ -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_remove(struct efx_tx_queue *tx_queue);
void efx_mcdi_tx_fini(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_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_remove(struct efx_rx_queue *rx_queue);
void efx_mcdi_rx_fini(struct efx_rx_queue *rx_queue); void efx_mcdi_rx_fini(struct efx_rx_queue *rx_queue);
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment