Skip to content

Commit

Permalink
sfc/siena: Rename functions in nic_common.h to avoid conflicts with sfc
Browse files Browse the repository at this point in the history
For siena use efx_siena_ as the function prefix.
efx_nic_update_stats_atomic is only used in efx_common.c, so move
it there.
efx_nic_copy_stats is not used in Siena, so it is removed.

Signed-off-by: Martin Habets <habetsm.xilinx@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Martin Habets authored and Jakub Kicinski committed May 10, 2022
1 parent 4d49e5c commit c8443b6
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 138 deletions.
6 changes: 3 additions & 3 deletions drivers/net/ethernet/sfc/siena/efx.c
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ static void efx_pci_remove_main(struct efx_nic *efx)

efx_siena_disable_interrupts(efx);
efx_siena_clear_interrupt_affinity(efx);
efx_nic_fini_interrupt(efx);
efx_siena_fini_interrupt(efx);
efx_fini_port(efx);
efx->type->fini(efx);
efx_siena_fini_napi(efx);
Expand Down Expand Up @@ -939,7 +939,7 @@ static int efx_pci_probe_main(struct efx_nic *efx)
goto fail4;
}

rc = efx_nic_init_interrupt(efx);
rc = efx_siena_init_interrupt(efx);
if (rc)
goto fail5;

Expand All @@ -952,7 +952,7 @@ static int efx_pci_probe_main(struct efx_nic *efx)

fail6:
efx_siena_clear_interrupt_affinity(efx);
efx_nic_fini_interrupt(efx);
efx_siena_fini_interrupt(efx);
fail5:
efx_fini_port(efx);
fail4:
Expand Down
10 changes: 9 additions & 1 deletion drivers/net/ethernet/sfc/siena/efx_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,14 +597,22 @@ void efx_siena_stop_all(struct efx_nic *efx)
efx_stop_datapath(efx);
}

static size_t efx_siena_update_stats_atomic(struct efx_nic *efx, u64 *full_stats,
struct rtnl_link_stats64 *core_stats)
{
if (efx->type->update_stats_atomic)
return efx->type->update_stats_atomic(efx, full_stats, core_stats);
return efx->type->update_stats(efx, full_stats, core_stats);
}

/* Context: process, dev_base_lock or RTNL held, non-blocking. */
void efx_siena_net_stats(struct net_device *net_dev,
struct rtnl_link_stats64 *stats)
{
struct efx_nic *efx = netdev_priv(net_dev);

spin_lock_bh(&efx->stats_lock);
efx_nic_update_stats_atomic(efx, NULL, stats);
efx_siena_update_stats_atomic(efx, NULL, stats);
spin_unlock_bh(&efx->stats_lock);
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/sfc/siena/ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static int efx_ethtool_phys_id(struct net_device *net_dev,

static int efx_ethtool_get_regs_len(struct net_device *net_dev)
{
return efx_nic_get_regs_len(netdev_priv(net_dev));
return efx_siena_get_regs_len(netdev_priv(net_dev));
}

static void efx_ethtool_get_regs(struct net_device *net_dev,
Expand All @@ -64,7 +64,7 @@ static void efx_ethtool_get_regs(struct net_device *net_dev,
struct efx_nic *efx = netdev_priv(net_dev);

regs->version = efx->type->revision;
efx_nic_get_regs(efx, buf);
efx_siena_get_regs(efx, buf);
}

/*
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/sfc/siena/farch.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ static int efx_alloc_special_buffer(struct efx_nic *efx,
#endif
len = ALIGN(len, EFX_BUF_SIZE);

if (efx_nic_alloc_buffer(efx, &buffer->buf, len, GFP_KERNEL))
if (efx_siena_alloc_buffer(efx, &buffer->buf, len, GFP_KERNEL))
return -ENOMEM;
buffer->entries = len / EFX_BUF_SIZE;
BUG_ON(buffer->buf.dma_addr & (EFX_BUF_SIZE - 1));
Expand Down Expand Up @@ -269,7 +269,7 @@ efx_free_special_buffer(struct efx_nic *efx, struct efx_special_buffer *buffer)
(u64)buffer->buf.dma_addr, buffer->buf.len,
buffer->buf.addr, (u64)virt_to_phys(buffer->buf.addr));

efx_nic_free_buffer(efx, &buffer->buf);
efx_siena_free_buffer(efx, &buffer->buf);
buffer->entries = 0;
}

Expand Down
9 changes: 4 additions & 5 deletions drivers/net/ethernet/sfc/siena/mcdi_mon.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,9 @@ int efx_siena_mcdi_mon_probe(struct efx_nic *efx)
if (n_sensors == 0)
return 0;

rc = efx_nic_alloc_buffer(
efx, &hwmon->dma_buf,
n_sensors * MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_LEN,
GFP_KERNEL);
rc = efx_siena_alloc_buffer(efx, &hwmon->dma_buf,
n_sensors * MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_LEN,
GFP_KERNEL);
if (rc)
return rc;

Expand Down Expand Up @@ -526,7 +525,7 @@ void efx_siena_mcdi_mon_remove(struct efx_nic *efx)
hwmon_device_unregister(hwmon->device);
kfree(hwmon->attrs);
kfree(hwmon->group.attrs);
efx_nic_free_buffer(efx, &hwmon->dma_buf);
efx_siena_free_buffer(efx, &hwmon->dma_buf);
}

#endif /* CONFIG_SFC_MCDI_MON */
7 changes: 4 additions & 3 deletions drivers/net/ethernet/sfc/siena/mcdi_port_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1225,8 +1225,9 @@ int efx_siena_mcdi_mac_init_stats(struct efx_nic *efx)
return 0;

/* Allocate buffer for stats */
rc = efx_nic_alloc_buffer(efx, &efx->stats_buffer,
efx->num_mac_stats * sizeof(u64), GFP_KERNEL);
rc = efx_siena_alloc_buffer(efx, &efx->stats_buffer,
efx->num_mac_stats * sizeof(u64),
GFP_KERNEL);
if (rc) {
netif_warn(efx, probe, efx->net_dev,
"failed to allocate DMA buffer: %d\n", rc);
Expand All @@ -1244,7 +1245,7 @@ int efx_siena_mcdi_mac_init_stats(struct efx_nic *efx)

void efx_siena_mcdi_mac_fini_stats(struct efx_nic *efx)
{
efx_nic_free_buffer(efx, &efx->stats_buffer);
efx_siena_free_buffer(efx, &efx->stats_buffer);
}

static unsigned int efx_mcdi_event_link_speed[] = {
Expand Down
79 changes: 18 additions & 61 deletions drivers/net/ethernet/sfc/siena/nic.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
*
**************************************************************************/

int efx_nic_alloc_buffer(struct efx_nic *efx, struct efx_buffer *buffer,
unsigned int len, gfp_t gfp_flags)
int efx_siena_alloc_buffer(struct efx_nic *efx, struct efx_buffer *buffer,
unsigned int len, gfp_t gfp_flags)
{
buffer->addr = dma_alloc_coherent(&efx->pci_dev->dev, len,
&buffer->dma_addr, gfp_flags);
Expand All @@ -39,7 +39,7 @@ int efx_nic_alloc_buffer(struct efx_nic *efx, struct efx_buffer *buffer,
return 0;
}

void efx_nic_free_buffer(struct efx_nic *efx, struct efx_buffer *buffer)
void efx_siena_free_buffer(struct efx_nic *efx, struct efx_buffer *buffer)
{
if (buffer->addr) {
dma_free_coherent(&efx->pci_dev->dev, buffer->len,
Expand All @@ -51,19 +51,19 @@ void efx_nic_free_buffer(struct efx_nic *efx, struct efx_buffer *buffer)
/* Check whether an event is present in the eventq at the current
* read pointer. Only useful for self-test.
*/
bool efx_nic_event_present(struct efx_channel *channel)
bool efx_siena_event_present(struct efx_channel *channel)
{
return efx_event_present(efx_event(channel, channel->eventq_read_ptr));
}

void efx_nic_event_test_start(struct efx_channel *channel)
void efx_siena_event_test_start(struct efx_channel *channel)
{
channel->event_test_cpu = -1;
smp_wmb();
channel->efx->type->ev_test_generate(channel);
}

int efx_nic_irq_test_start(struct efx_nic *efx)
int efx_siena_irq_test_start(struct efx_nic *efx)
{
efx->last_irq_cpu = -1;
smp_wmb();
Expand All @@ -73,7 +73,7 @@ int efx_nic_irq_test_start(struct efx_nic *efx)
/* Hook interrupt handler(s)
* Try MSI and then legacy interrupts.
*/
int efx_nic_init_interrupt(struct efx_nic *efx)
int efx_siena_init_interrupt(struct efx_nic *efx)
{
struct efx_channel *channel;
unsigned int n_irqs;
Expand Down Expand Up @@ -146,7 +146,7 @@ int efx_nic_init_interrupt(struct efx_nic *efx)
return rc;
}

void efx_nic_fini_interrupt(struct efx_nic *efx)
void efx_siena_fini_interrupt(struct efx_nic *efx)
{
struct efx_channel *channel;

Expand Down Expand Up @@ -364,7 +364,7 @@ static const struct efx_nic_reg_table efx_nic_reg_tables[] = {
REGISTER_TABLE_BZ(RX_FILTER_TBL0),
};

size_t efx_nic_get_regs_len(struct efx_nic *efx)
size_t efx_siena_get_regs_len(struct efx_nic *efx)
{
const struct efx_nic_reg *reg;
const struct efx_nic_reg_table *table;
Expand All @@ -387,7 +387,7 @@ size_t efx_nic_get_regs_len(struct efx_nic *efx)
return len;
}

void efx_nic_get_regs(struct efx_nic *efx, void *buf)
void efx_siena_get_regs(struct efx_nic *efx, void *buf)
{
const struct efx_nic_reg *reg;
const struct efx_nic_reg_table *table;
Expand Down Expand Up @@ -439,7 +439,7 @@ void efx_nic_get_regs(struct efx_nic *efx, void *buf)
}

/**
* efx_nic_describe_stats - Describe supported statistics for ethtool
* efx_siena_describe_stats - Describe supported statistics for ethtool
* @desc: Array of &struct efx_hw_stat_desc describing the statistics
* @count: Length of the @desc array
* @mask: Bitmask of which elements of @desc are enabled
Expand All @@ -449,8 +449,8 @@ void efx_nic_get_regs(struct efx_nic *efx, void *buf)
* Returns the number of visible statistics, i.e. the number of set
* bits in the first @count bits of @mask for which a name is defined.
*/
size_t efx_nic_describe_stats(const struct efx_hw_stat_desc *desc, size_t count,
const unsigned long *mask, u8 *names)
size_t efx_siena_describe_stats(const struct efx_hw_stat_desc *desc, size_t count,
const unsigned long *mask, u8 *names)
{
size_t visible = 0;
size_t index;
Expand All @@ -470,50 +470,7 @@ size_t efx_nic_describe_stats(const struct efx_hw_stat_desc *desc, size_t count,
}

/**
* efx_nic_copy_stats - Copy stats from the DMA buffer in to an
* intermediate buffer. This is used to get a consistent
* set of stats while the DMA buffer can be written at any time
* by the NIC.
* @efx: The associated NIC.
* @dest: Destination buffer. Must be the same size as the DMA buffer.
*/
int efx_nic_copy_stats(struct efx_nic *efx, __le64 *dest)
{
__le64 *dma_stats = efx->stats_buffer.addr;
__le64 generation_start, generation_end;
int rc = 0, retry;

if (!dest)
return 0;

if (!dma_stats)
goto return_zeroes;

/* If we're unlucky enough to read statistics during the DMA, wait
* up to 10ms for it to finish (typically takes <500us)
*/
for (retry = 0; retry < 100; ++retry) {
generation_end = dma_stats[efx->num_mac_stats - 1];
if (generation_end == EFX_MC_STATS_GENERATION_INVALID)
goto return_zeroes;
rmb();
memcpy(dest, dma_stats, efx->num_mac_stats * sizeof(__le64));
rmb();
generation_start = dma_stats[MC_CMD_MAC_GENERATION_START];
if (generation_end == generation_start)
return 0; /* return good data */
udelay(100);
}

rc = -EIO;

return_zeroes:
memset(dest, 0, efx->num_mac_stats * sizeof(u64));
return rc;
}

/**
* efx_nic_update_stats - Convert statistics DMA buffer to array of u64
* efx_siena_update_stats - Convert statistics DMA buffer to array of u64
* @desc: Array of &struct efx_hw_stat_desc describing the DMA buffer
* layout. DMA widths of 0, 16, 32 and 64 are supported; where
* the width is specified as 0 the corresponding element of
Expand All @@ -526,9 +483,9 @@ int efx_nic_copy_stats(struct efx_nic *efx, __le64 *dest)
* @accumulate: If set, the converted values will be added rather than
* directly stored to the corresponding elements of @stats
*/
void efx_nic_update_stats(const struct efx_hw_stat_desc *desc, size_t count,
const unsigned long *mask,
u64 *stats, const void *dma_buf, bool accumulate)
void efx_siena_update_stats(const struct efx_hw_stat_desc *desc, size_t count,
const unsigned long *mask,
u64 *stats, const void *dma_buf, bool accumulate)
{
size_t index;

Expand Down Expand Up @@ -561,7 +518,7 @@ void efx_nic_update_stats(const struct efx_hw_stat_desc *desc, size_t count,
}
}

void efx_nic_fix_nodesc_drop_stat(struct efx_nic *efx, u64 *rx_nodesc_drops)
void efx_siena_fix_nodesc_drop_stat(struct efx_nic *efx, u64 *rx_nodesc_drops)
{
/* if down, or this is the first update after coming up */
if (!(efx->net_dev->flags & IFF_UP) || !efx->rx_nodesc_drops_prev_state)
Expand Down
40 changes: 16 additions & 24 deletions drivers/net/ethernet/sfc/siena/nic_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ static inline void efx_nic_eventq_read_ack(struct efx_channel *channel)
channel->efx->type->ev_read_ack(channel);
}

void efx_nic_event_test_start(struct efx_channel *channel);
void efx_siena_event_test_start(struct efx_channel *channel);

bool efx_nic_event_present(struct efx_channel *channel);
bool efx_siena_event_present(struct efx_channel *channel);

static inline void efx_sensor_event(struct efx_nic *efx, efx_qword_t *ev)
{
Expand Down Expand Up @@ -216,9 +216,9 @@ static inline void efx_update_diff_stat(u64 *stat, u64 diff)
}

/* Interrupts */
int efx_nic_init_interrupt(struct efx_nic *efx);
int efx_nic_irq_test_start(struct efx_nic *efx);
void efx_nic_fini_interrupt(struct efx_nic *efx);
int efx_siena_init_interrupt(struct efx_nic *efx);
int efx_siena_irq_test_start(struct efx_nic *efx);
void efx_siena_fini_interrupt(struct efx_nic *efx);

static inline int efx_nic_event_test_irq_cpu(struct efx_channel *channel)
{
Expand All @@ -230,29 +230,21 @@ static inline int efx_nic_irq_test_irq_cpu(struct efx_nic *efx)
}

/* Global Resources */
int efx_nic_alloc_buffer(struct efx_nic *efx, struct efx_buffer *buffer,
unsigned int len, gfp_t gfp_flags);
void efx_nic_free_buffer(struct efx_nic *efx, struct efx_buffer *buffer);
int efx_siena_alloc_buffer(struct efx_nic *efx, struct efx_buffer *buffer,
unsigned int len, gfp_t gfp_flags);
void efx_siena_free_buffer(struct efx_nic *efx, struct efx_buffer *buffer);

size_t efx_nic_get_regs_len(struct efx_nic *efx);
void efx_nic_get_regs(struct efx_nic *efx, void *buf);
size_t efx_siena_get_regs_len(struct efx_nic *efx);
void efx_siena_get_regs(struct efx_nic *efx, void *buf);

#define EFX_MC_STATS_GENERATION_INVALID ((__force __le64)(-1))

size_t efx_nic_describe_stats(const struct efx_hw_stat_desc *desc, size_t count,
const unsigned long *mask, u8 *names);
int efx_nic_copy_stats(struct efx_nic *efx, __le64 *dest);
void efx_nic_update_stats(const struct efx_hw_stat_desc *desc, size_t count,
const unsigned long *mask, u64 *stats,
const void *dma_buf, bool accumulate);
void efx_nic_fix_nodesc_drop_stat(struct efx_nic *efx, u64 *stat);
static inline size_t efx_nic_update_stats_atomic(struct efx_nic *efx, u64 *full_stats,
struct rtnl_link_stats64 *core_stats)
{
if (efx->type->update_stats_atomic)
return efx->type->update_stats_atomic(efx, full_stats, core_stats);
return efx->type->update_stats(efx, full_stats, core_stats);
}
size_t efx_siena_describe_stats(const struct efx_hw_stat_desc *desc, size_t count,
const unsigned long *mask, u8 *names);
void efx_siena_update_stats(const struct efx_hw_stat_desc *desc, size_t count,
const unsigned long *mask, u64 *stats,
const void *dma_buf, bool accumulate);
void efx_siena_fix_nodesc_drop_stat(struct efx_nic *efx, u64 *stat);

#define EFX_MAX_FLUSH_TIME 5000

Expand Down
Loading

0 comments on commit c8443b6

Please sign in to comment.