Skip to content

Commit

Permalink
onload_mktest_net_driver: Replacing net driver with cea15c18d85a4aab4…
Browse files Browse the repository at this point in the history
…3893b2d3984606c24a8f638
  • Loading branch information
tcrawley-xilinx committed Jan 21, 2025
1 parent 03a7a56 commit 95d1602
Show file tree
Hide file tree
Showing 20 changed files with 580 additions and 348 deletions.
72 changes: 72 additions & 0 deletions src/driver/linux_net/drivers/net/ethernet/sfc/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,38 @@ static void efx_fini_debugfs_rx_queue(struct efx_rx_queue *rx_queue)
rx_queue->debug_dir = NULL;
}

/* Per-channel_type parameters */
#ifdef EFX_NOT_UPSTREAM
static const char *const client_type_names[] = {
[EFX_CLIENT_ETH] = "Full-featured ethernet",
[EFX_CLIENT_LLCT] = "Low-latency Cut-through",
[EFX_CLIENT_ONLOAD] = "Full-featured Onload",
};

static const unsigned int client_type_max = sizeof(client_type_names);

static int efx_debugfs_read_client_type(struct seq_file *file, void *data)
{
unsigned int value = *(enum efx_client_type *)data;

BUILD_BUG_ON(ARRAY_SIZE(client_type_names) != _EFX_CLIENT_MAX);

seq_printf(file, "%d => %s\n", value,
STRING_TABLE_LOOKUP(value, client_type));
return 0;
}

#define EFX_CLIENT_TYPE_PARAMETER(container_type, parameter) \
EFX_PARAMETER(container_type, parameter, \
enum efx_client_type, efx_debugfs_read_client_type)
#endif

static const struct efx_debugfs_parameter efx_debugfs_channel_type_parameters[] = {
#ifdef EFX_NOT_UPSTREAM
EFX_CLIENT_TYPE_PARAMETER(struct efx_channel_type, client_type),
#endif
};

/* Per-channel parameters */
static const struct efx_debugfs_parameter efx_debugfs_channel_parameters[] = {
EFX_BOOL_PARAMETER(struct efx_channel, enabled),
Expand All @@ -861,6 +893,13 @@ static void *efx_debugfs_get_channel(void *ref, unsigned int index)
return efx_get_channel(ref, index);
}

static void *efx_debugfs_get_channel_type(void *ref, unsigned int index)
{
struct efx_channel *channel = efx_get_channel(ref, index);

return channel ? (void *)channel->type : NULL;
}

static void efx_fini_debugfs_channel(struct efx_channel *channel);

/**
Expand Down Expand Up @@ -898,6 +937,12 @@ static int efx_init_debugfs_channel(struct efx_channel *channel)
if (rc)
goto err;

rc = efx_init_debugfs_files(channel->debug_dir,
efx_debugfs_channel_type_parameters, 0,
efx_debugfs_get_channel_type, channel->efx,
channel->channel);
if (rc)
goto err;
return 0;

err_len:
Expand All @@ -912,6 +957,27 @@ static int efx_init_debugfs_channel(struct efx_channel *channel)
return rc;
}

/**
* efx_fini_debugfs_channel_type_files - remove channel type files
* @channel: Efx channel
*
* Remove channel type files only. Leave directory otherwise intact.
*/
static void efx_fini_debugfs_channel_type_files(struct efx_channel *channel)
{
const struct efx_debugfs_parameter *param =
efx_debugfs_channel_type_parameters;
struct dentry *dir = channel->debug_dir;

if (!dir)
return;

while (param->name) {
efx_fini_debugfs_child(dir, param->name);
param++;
}
}

/**
* efx_fini_debugfs_channel - remove debugfs directory for channel
* @channel: Efx channel
Expand All @@ -920,6 +986,12 @@ static int efx_init_debugfs_channel(struct efx_channel *channel)
*/
static void efx_fini_debugfs_channel(struct efx_channel *channel)
{
/* Channel parameters and channel type parameters share the same
* debugfs directory but are separate parameter lists. First remove
* channel type files. Then remove channel parameter files. Finally
* remove channel debugfs directory.
*/
efx_fini_debugfs_channel_type_files(channel);
efx_fini_debugfs_dir(channel->debug_dir,
efx_debugfs_channel_parameters, NULL);
channel->debug_dir = NULL;
Expand Down
28 changes: 5 additions & 23 deletions src/driver/linux_net/drivers/net/ethernet/sfc/ef10.c
Original file line number Diff line number Diff line change
Expand Up @@ -1378,10 +1378,6 @@ static void efx_ef10_fini_nic(struct efx_nic *efx)

kfree(nic_data->mc_stats);
nic_data->mc_stats = NULL;

if (!efx_ptp_uses_separate_channel(efx) &&
!efx_ptp_use_mac_tx_timestamps(efx))
efx_ptp_remove(efx);
}

static int efx_ef10_init_nic(struct efx_nic *efx)
Expand Down Expand Up @@ -1478,10 +1474,6 @@ static int efx_ef10_init_nic(struct efx_nic *efx)
#endif
#endif

if (!efx_ptp_uses_separate_channel(efx) &&
!efx_ptp_use_mac_tx_timestamps(efx))
efx_ptp_probe(efx, NULL);

return 0;
}

Expand Down Expand Up @@ -2479,7 +2471,7 @@ static irqreturn_t efx_ef10_msi_interrupt(int irq, void *dev_id)
efx->last_irq_cpu = raw_smp_processor_id();

/* Schedule processing of the channel */
channel = efx_get_channel(efx, context->index);
channel = efx_get_channel(efx, context->channel);
efx_schedule_channel_irq(channel);
}

Expand Down Expand Up @@ -5674,21 +5666,16 @@ static int efx_ef10_probe_pf(struct efx_nic *efx)

static int efx_x4_probe_pf(struct efx_nic *efx)
{
int rc = efx_ef10_probe_pf(efx);

#ifdef EFX_NOT_UPSTREAM
if (rc)
return rc;

int rc;
rc = efx_ll_init(efx);
if (rc)
pci_info(efx->pci_dev,
"Low latency datapath initialisation failed with error %d. Continuing without it.\n",
rc);

rc = 0;
#endif
return rc;
return efx_ef10_probe_pf(efx);
}

static void efx_ef10_remove(struct efx_nic *efx)
Expand Down Expand Up @@ -5807,21 +5794,16 @@ static int efx_ef10_probe_vf(struct efx_nic *efx)

static int efx_x4_probe_vf(struct efx_nic *efx)
{
int rc = efx_ef10_probe_vf(efx);

#ifdef EFX_NOT_UPSTREAM
if (rc)
return rc;

int rc;
rc = efx_ll_init(efx);
if (rc)
pci_info(efx->pci_dev,
"Low latency datapath initialisation failed with error %d. Continuing without it.\n",
rc);

rc = 0;
#endif
return rc;
return efx_ef10_probe_vf(efx);
}
#endif /* CONFIG_SFC_SRIOV */

Expand Down
6 changes: 3 additions & 3 deletions src/driver/linux_net/drivers/net/ethernet/sfc/ef100_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,6 @@ void ef100_remove_netdev(struct efx_probe_data *probe_data)
#endif

efx_mcdi_filter_table_remove(efx);
efx_fini_interrupts(efx);
efx_mcdi_mac_fini_stats(efx);
kfree(efx->phy_data);
efx->phy_data = NULL;
Expand All @@ -867,7 +866,7 @@ int ef100_probe_netdev(struct efx_probe_data *probe_data)
struct ef100_nic_data *nic_data;
struct efx_probe_data **probe_ptr;
struct net_device *net_dev;
int rc;
int rc, max_irqs;

#if !defined(EFX_USE_KCOMPAT) || !defined(EFX_TC_OFFLOAD)
if (efx->mcdi->fn_flags &
Expand Down Expand Up @@ -929,9 +928,10 @@ int ef100_probe_netdev(struct efx_probe_data *probe_data)
rc = efx_init_interrupts(efx);
if (rc < 0)
goto fail;
max_irqs = rc;

/* Update maximum channel count for ethtool */
efx->max_channels = min_t(u16, efx->max_channels, efx->max_irqs);
efx->max_channels = min_t(u16, efx->max_channels, max_irqs);
efx->max_tx_channels = efx->max_channels;

rc = ef100_filter_table_probe(efx);
Expand Down
2 changes: 1 addition & 1 deletion src/driver/linux_net/drivers/net/ethernet/sfc/ef100_nic.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ static irqreturn_t ef100_msi_interrupt(int irq, void *dev_id)
struct efx_nic *efx = context->efx;
struct efx_channel *channel;

channel = efx_get_channel(efx, context->index);
channel = efx_get_channel(efx, context->channel);
netif_vdbg(efx, intr, efx->net_dev,
"IRQ %d on CPU %d\n", irq, raw_smp_processor_id());

Expand Down
11 changes: 5 additions & 6 deletions src/driver/linux_net/drivers/net/ethernet/sfc/efx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,6 @@ void efx_pci_remove_post_io(struct efx_nic *efx,
efx->type->sriov_fini(efx);
if (efx->type->vswitching_remove)
efx->type->vswitching_remove(efx);
efx_fini_interrupts(efx);
#ifdef CONFIG_SFC_PTP
efx_ptp_remove_post_io(efx);
#endif
Expand All @@ -1047,7 +1046,7 @@ void efx_pci_remove_post_io(struct efx_nic *efx,
int efx_pci_probe_post_io(struct efx_nic *efx,
int (*nic_probe)(struct efx_nic *efx))
{
int rc;
int rc, max_irqs;

#ifdef EFX_NOT_UPSTREAM
if (!performance_profile)
Expand Down Expand Up @@ -1132,12 +1131,12 @@ int efx_pci_probe_post_io(struct efx_nic *efx,
if (rc)
return rc;

rc = efx_init_interrupts(efx);
if (rc < 0)
return rc;
max_irqs = efx_init_interrupts(efx);
if (max_irqs < 0)
return max_irqs;

/* Update maximum channel count for ethtool */
efx->max_channels = min_t(u16, efx->max_channels, efx->max_irqs);
efx->max_channels = min_t(u16, efx->max_channels, max_irqs);
efx->max_tx_channels = efx->max_channels;

rc = efx->type->vswitching_probe(efx);
Expand Down
74 changes: 73 additions & 1 deletion src/driver/linux_net/drivers/net/ethernet/sfc/efx_auxbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ struct efx_auxdev_client *efx_auxbus_open_common(struct auxiliary_device *auxdev
cdev->auxdev = adev;
cdev->events_requested = events_requested;
efx_auxbus_init_queues(cdev);
xa_init(&cdev->irqs);
return cdev;
}

Expand Down Expand Up @@ -239,7 +240,10 @@ static void efx_auxbus_destroy_queues(struct efx_auxdev_client *cdev)
static void efx_auxbus_close(struct efx_auxdev_client *cdev)
{
struct efx_client_type_data *client_type;
struct efx_auxdev_irq *entry;
struct efx_probe_data *pd;
struct efx_client *client;
unsigned long index;

if (!cdev)
return;
Expand All @@ -252,6 +256,16 @@ static void efx_auxbus_close(struct efx_auxdev_client *cdev)
client_type = client->client_type;
efx_auxbus_wait_for_event_callbacks(client_type);

pd = cdev_to_probe_data(cdev);
xa_for_each(&cdev->irqs, index, entry) {
if (!entry)
continue;
if (pd)
efx_nic_free_irq(pd, entry->nic_nr);
kfree(entry);
}
xa_destroy(&cdev->irqs);

efx_auxbus_destroy_queues(cdev);
cdev->net_dev = NULL;
cdev->client_id = 0;
Expand Down Expand Up @@ -1158,12 +1172,70 @@ static void efx_auxbus_rxq_free(struct efx_auxdev_client *handle, int rxq_nr)
static
struct efx_auxdev_irq *efx_auxbus_irq_alloc(struct efx_auxdev_client *handle)
{
return ERR_PTR(-EOPNOTSUPP);
struct efx_msi_context *msi_context;
struct efx_auxdev_irq *irq;
struct efx_probe_data *pd;
void *xa_res;
int rc;

if (!handle)
return ERR_PTR(-EINVAL);

pd = cdev_to_probe_data(handle);
if (!pd)
return ERR_PTR(-EINVAL);

irq = kzalloc(sizeof(*irq), GFP_KERNEL);
if (!irq)
return ERR_PTR(-ENOMEM);

msi_context = efx_nic_alloc_irq(pd, &irq->os_vector);
if (IS_ERR(msi_context)) {
rc = PTR_ERR(msi_context);
goto fail;
}

irq->nic_nr = msi_context->index;

xa_res = xa_store(&handle->irqs, irq->nic_nr, irq, GFP_KERNEL);
if (xa_is_err(xa_res)) {
rc = xa_err(xa_res);
goto fail_free_irq;
}

return irq;

fail_free_irq:
efx_nic_free_irq(pd, irq->nic_nr);
fail:
kfree(irq);
return ERR_PTR(rc);
}

static void efx_auxbus_irq_free(struct efx_auxdev_client *handle,
struct efx_auxdev_irq *irq)
{
struct efx_auxdev_irq *xa_res;
struct efx_probe_data *pd;

if (!handle)
return;
if (!irq)
return;

pd = cdev_to_probe_data(handle);
if (!pd)
return;

xa_res = xa_erase(&handle->irqs, irq->nic_nr);
if (xa_is_err(xa_res))
return;

if (xa_res != irq)
return;

efx_nic_free_irq(pd, irq->nic_nr);
kfree(irq);
}

static const struct efx_auxdev_llct_ops aux_llct_devops = {
Expand Down
Loading

0 comments on commit 95d1602

Please sign in to comment.