Skip to content

Commit

Permalink
onload_mktest_net_driver: Replacing net driver with v6_0_2_1002
Browse files Browse the repository at this point in the history
  • Loading branch information
ivatet-amd committed Jan 13, 2025
1 parent 6fbb622 commit 381b9e5
Show file tree
Hide file tree
Showing 21 changed files with 2,070 additions and 212 deletions.
2 changes: 1 addition & 1 deletion src/driver/linux_net/drivers/net/ethernet/sfc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ endif # !EFX_NO_KCOMPAT
ifndef EFX_UPSTREAM
ifeq ($(filter export export-xen,$(MAKECMDGOALS)),)
ifndef EFX_FOR_UPSTREAM
sfc-y += sfctool.o efx_client.o
sfc-y += sfctool.o efx_client.o efx_ll.o
sfc-$(CONFIG_AUXILIARY_BUS) += efx_auxbus.o
sfc-$(CONFIG_SFC_EF100) += ef100_dump.o
sfc-$(CONFIG_SFC_VDPA) += ef100_vdpa_dbg.o
Expand Down
70 changes: 65 additions & 5 deletions src/driver/linux_net/drivers/net/ethernet/sfc/ef10.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#endif
#ifdef EFX_NOT_UPSTREAM
#include "efx_ioctl.h"
#include "efx_ll.h"
#endif
#include <linux/module.h>
#include "debugfs.h"
Expand Down Expand Up @@ -3310,6 +3311,10 @@ efx_ef10_handle_rx_event_errors(struct efx_rx_queue *rx_queue,
}
handled = true;
}
if (EFX_QWORD_FIELD(*event, ESF_DZ_RX_TRUNC_ERR)) {
rx_queue->n_rx_frm_trunc += n_packets;
return EFX_RX_PKT_DISCARD;
}
if (EFX_QWORD_FIELD(*event, ESF_DZ_RX_IPCKSUM_ERR)) {
if (unlikely(rx_encap_hdr != ESE_EZ_ENCAP_HDR_VXLAN &&
rx_l3_class != ESE_DZ_L3_CLASS_IP4 &&
Expand Down Expand Up @@ -3476,7 +3481,8 @@ static int efx_ef10_handle_rx_event(struct efx_channel *channel,
n_packets = 1;
}

EFX_POPULATE_QWORD_5(errors, ESF_DZ_RX_ECRC_ERR, 1,
EFX_POPULATE_QWORD_6(errors, ESF_DZ_RX_ECRC_ERR, 1,
ESF_DZ_RX_TRUNC_ERR, 1,
ESF_DZ_RX_IPCKSUM_ERR, 1,
ESF_DZ_RX_TCPUDP_CKSUM_ERR, 1,
ESF_EZ_RX_IP_INNER_CHKSUM_ERR, 1,
Expand Down Expand Up @@ -5666,6 +5672,25 @@ static int efx_ef10_probe_pf(struct efx_nic *efx)
return efx_ef10_probe(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;

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;
}

static void efx_ef10_remove(struct efx_nic *efx)
{
struct efx_ef10_nic_data *nic_data = efx->nic_data;
Expand All @@ -5686,6 +5711,14 @@ static void efx_ef10_remove(struct efx_nic *efx)
efx->nic_data = NULL;
}

static void efx_x4_remove(struct efx_nic *efx)
{
#ifdef EFX_NOT_UPSTREAM
efx_ll_fini(efx);
#endif
efx_ef10_remove(efx);
}

#if defined(CONFIG_SFC_SRIOV)
static void efx_ef10_remove_vf(struct efx_nic *efx)
{
Expand All @@ -5712,6 +5745,14 @@ static void efx_ef10_remove_vf(struct efx_nic *efx)
}
}

static void efx_x4_remove_vf(struct efx_nic *efx)
{
#ifdef EFX_NOT_UPSTREAM
efx_ll_fini(efx);
#endif
efx_ef10_remove_vf(efx);
}

static int efx_ef10_probe_vf(struct efx_nic *efx)
{
struct efx_ef10_nic_data *nic_data;
Expand Down Expand Up @@ -5763,6 +5804,25 @@ static int efx_ef10_probe_vf(struct efx_nic *efx)
efx_ef10_remove_vf(efx);
return rc;
}

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;

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;
}
#endif /* CONFIG_SFC_SRIOV */

static unsigned int ef10_check_caps(const struct efx_nic *efx,
Expand Down Expand Up @@ -5985,8 +6045,8 @@ const struct efx_nic_type efx_x4_vf_nic_type = {
.is_vf = true,
.mem_bar = efx_x4_vf_mem_bar,
.mem_map_size = efx_ef10_initial_mem_map_size,
.probe = efx_ef10_probe_vf,
.remove = efx_ef10_remove_vf,
.probe = efx_x4_probe_vf,
.remove = efx_x4_remove_vf,
.dimension_resources = efx_ef10_dimension_resources,
.net_alloc = __efx_net_alloc,
.net_dealloc = __efx_net_dealloc,
Expand Down Expand Up @@ -6329,8 +6389,8 @@ const struct efx_nic_type efx_x4_nic_type = {
.is_vf = false,
.mem_bar = efx_ef10_pf_mem_bar,
.mem_map_size = efx_ef10_initial_mem_map_size,
.probe = efx_ef10_probe_pf,
.remove = efx_ef10_remove,
.probe = efx_x4_probe_pf,
.remove = efx_x4_remove,
.dimension_resources = efx_ef10_dimension_resources,
.free_resources = efx_ef10_free_resources,
.net_alloc = __efx_net_alloc,
Expand Down
85 changes: 4 additions & 81 deletions src/driver/linux_net/drivers/net/ethernet/sfc/ef100_nic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1402,58 +1402,8 @@ static ssize_t bar_config_store(struct device *dev,
static DEVICE_ATTR_RW(bar_config);
#endif

enum ef100_tlv_state_machine {
EF100_TLV_TYPE,
EF100_TLV_TYPE_CONT,
EF100_TLV_LENGTH,
EF100_TLV_VALUE
};

struct ef100_tlv_state {
enum ef100_tlv_state_machine state;
u64 value;
u32 value_offset;
u16 type;
u8 len;
};

static int ef100_tlv_feed(struct ef100_tlv_state *state, u8 byte)
{
switch (state->state) {
case EF100_TLV_TYPE:
state->type = byte & 0x7f;
state->state = (byte & 0x80) ? EF100_TLV_TYPE_CONT
: EF100_TLV_LENGTH;
/* Clear ready to read in a new entry */
state->value = 0;
state->value_offset = 0;
return 0;
case EF100_TLV_TYPE_CONT:
state->type |= byte << 7;
state->state = EF100_TLV_LENGTH;
return 0;
case EF100_TLV_LENGTH:
state->len = byte;
/* We only handle TLVs that fit in a u64 */
if (state->len > sizeof(state->value))
return -EOPNOTSUPP;
/* len may be zero, implying a value of zero */
state->state = state->len ? EF100_TLV_VALUE : EF100_TLV_TYPE;
return 0;
case EF100_TLV_VALUE:
state->value |= ((u64)byte) << (state->value_offset * 8);
state->value_offset++;
if (state->value_offset >= state->len)
state->state = EF100_TLV_TYPE;
return 0;
default: /* state machine error, can't happen */
WARN_ON_ONCE(1);
return -EIO;
}
}

static int ef100_process_design_param(struct efx_nic *efx,
const struct ef100_tlv_state *reader)
const struct efx_tlv_state *reader)
{
struct ef100_nic_data *nic_data = efx->nic_data;

Expand Down Expand Up @@ -1562,35 +1512,6 @@ static int ef100_process_design_param(struct efx_nic *efx,
}
}

static int ef100_check_design_params(struct efx_nic *efx)
{
struct ef100_tlv_state reader = {};
u32 total_len, offset = 0;
efx_dword_t reg;
int rc = 0, i;
u32 data;

efx_readd(efx, &reg, ER_GZ_PARAMS_TLV_LEN);
total_len = EFX_DWORD_FIELD(reg, EFX_DWORD_0);
pci_dbg(efx->pci_dev, "%u bytes of design parameters\n", total_len);
while (offset < total_len) {
efx_readd(efx, &reg, ER_GZ_PARAMS_TLV + offset);
data = EFX_DWORD_FIELD(reg, EFX_DWORD_0);
for (i = 0; i < sizeof(data); i++) {
rc = ef100_tlv_feed(&reader, data);
/* Got a complete value? */
if (!rc && reader.state == EF100_TLV_TYPE)
rc = ef100_process_design_param(efx, &reader);
if (rc)
goto out;
data >>= 8;
offset++;
}
}
out:
return rc;
}

static int efx_ef100_update_client_id(struct efx_nic *efx)
{
struct ef100_nic_data *nic_data = efx->nic_data;
Expand Down Expand Up @@ -1653,7 +1574,9 @@ static int ef100_probe_main(struct efx_nic *efx)
nic_data->tso_max_payload_num_segs = ESE_EF100_DP_GZ_TSO_MAX_PAYLOAD_NUM_SEGS_DEFAULT;
nic_data->tso_max_payload_len = ESE_EF100_DP_GZ_TSO_MAX_PAYLOAD_LEN_DEFAULT;
/* Read design parameters */
rc = ef100_check_design_params(efx);
rc = efx_check_design_params(efx, ef100_process_design_param,
ER_GZ_PARAMS_TLV_LEN, ER_GZ_PARAMS_TLV,
bar_size, efx_readd);
if (rc) {
pci_err(efx->pci_dev, "Unsupported design parameters\n");
goto fail;
Expand Down
Loading

0 comments on commit 381b9e5

Please sign in to comment.