Skip to content

Commit

Permalink
net/axgbe: align with new API
Browse files Browse the repository at this point in the history
Signed-off-by: David Marchand <[email protected]>
  • Loading branch information
david-marchand committed Sep 21, 2023
1 parent 6ed4d82 commit 03d4aa7
Showing 1 changed file with 31 additions and 51 deletions.
82 changes: 31 additions & 51 deletions drivers/net/axgbe/axgbe_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
#include "axgbe_regs.h"
#include "rte_time.h"

#include "eal_cpu.h"
#include "eal_filesystem.h"

#include <cpuid.h>

static int eth_axgbe_dev_init(struct rte_eth_dev *eth_dev);
static int axgbe_dev_configure(struct rte_eth_dev *dev);
static int axgbe_dev_start(struct rte_eth_dev *dev);
Expand Down Expand Up @@ -175,13 +174,6 @@ static const struct axgbe_xstats axgbe_xstats_strings[] = {
/* The set of PCI devices this driver supports */
#define AMD_PCI_VENDOR_ID 0x1022

#define Fam17h 0x17
#define Fam19h 0x19

#define CPUID_VENDOR_AuthenticAMD_ebx 0x68747541
#define CPUID_VENDOR_AuthenticAMD_ecx 0x444d4163
#define CPUID_VENDOR_AuthenticAMD_edx 0x69746e65

#define AMD_PCI_AXGBE_DEVICE_V2A 0x1458
#define AMD_PCI_AXGBE_DEVICE_V2B 0x1459

Expand Down Expand Up @@ -2170,9 +2162,6 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
uint32_t len;
int ret;

unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0;
unsigned char cpu_family = 0, cpu_model = 0;

eth_dev->dev_ops = &axgbe_eth_dev_ops;

eth_dev->rx_descriptor_status = axgbe_dev_rx_descriptor_status;
Expand Down Expand Up @@ -2216,52 +2205,43 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
else
pdata->vdata = &axgbe_v2b;

/*
* Use CPUID to get Family and model ID to identify the CPU
*/
__cpuid(0x0, eax, ebx, ecx, edx);
if (rte_cpu_is_x86() && rte_cpu_x86_is_amd()) {
uint8_t cpu_family, cpu_model;
bool unknown_cpu = true;

if (ebx == CPUID_VENDOR_AuthenticAMD_ebx &&
edx == CPUID_VENDOR_AuthenticAMD_edx &&
ecx == CPUID_VENDOR_AuthenticAMD_ecx) {
int unknown_cpu = 0;
eax = 0, ebx = 0, ecx = 0, edx = 0;
cpu_family = rte_cpu_x86_family();
cpu_model = rte_cpu_x86_model();

__cpuid(0x1, eax, ebx, ecx, edx);
switch (cpu_family) {
case 0x17:
if (cpu_model >= 0x10 && cpu_model <= 0x1F) {
/* V1000/R1000 */
pdata->xpcs_window_def_reg = PCS_V2_RV_WINDOW_DEF;
pdata->xpcs_window_sel_reg = PCS_V2_RV_WINDOW_SELECT;
unknown_cpu = false;
} else if (cpu_model >= 0x01 && cpu_model <= 0x0F) {
/* EPYC 3000 */
pdata->xpcs_window_def_reg = PCS_V2_WINDOW_DEF;
pdata->xpcs_window_sel_reg = PCS_V2_WINDOW_SELECT;
unknown_cpu = false;
}
break;
case 0x19:
if (cpu_model >= 0x44 && cpu_model <= 0x47) {
/* V3000 (Yellow Carp) */
pdata->xpcs_window_def_reg = PCS_V2_YC_WINDOW_DEF;
pdata->xpcs_window_sel_reg = PCS_V2_YC_WINDOW_SELECT;

cpu_family = ((GET_BITS(eax, 8, 4)) + (GET_BITS(eax, 20, 8)));
cpu_model = ((GET_BITS(eax, 4, 4)) | (((GET_BITS(eax, 16, 4)) << 4) & 0xF0));
/* Yellow Carp devices do not need cdr workaround */
pdata->vdata->an_cdr_workaround = 0;

switch (cpu_family) {
case Fam17h:
/* V1000/R1000 */
if (cpu_model >= 0x10 && cpu_model <= 0x1F) {
pdata->xpcs_window_def_reg = PCS_V2_RV_WINDOW_DEF;
pdata->xpcs_window_sel_reg = PCS_V2_RV_WINDOW_SELECT;
/* EPYC 3000 */
} else if (cpu_model >= 0x01 && cpu_model <= 0x0F) {
pdata->xpcs_window_def_reg = PCS_V2_WINDOW_DEF;
pdata->xpcs_window_sel_reg = PCS_V2_WINDOW_SELECT;
} else {
unknown_cpu = 1;
}
break;
case Fam19h:
/* V3000 (Yellow Carp) */
if (cpu_model >= 0x44 && cpu_model <= 0x47) {
pdata->xpcs_window_def_reg = PCS_V2_YC_WINDOW_DEF;
pdata->xpcs_window_sel_reg = PCS_V2_YC_WINDOW_SELECT;

/* Yellow Carp devices do not need cdr workaround */
pdata->vdata->an_cdr_workaround = 0;
} else {
unknown_cpu = 1;
}
break;
unknown_cpu = false;
}
break;
default:
unknown_cpu = 1;
break;
}

if (unknown_cpu) {
PMD_DRV_LOG(ERR, "Unknown CPU family, no supported axgbe device found\n");
return -ENODEV;
Expand Down

0 comments on commit 03d4aa7

Please sign in to comment.