Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[Deepin Kernel SIG] ethernet: release motorcomm yt6801 v1.0.28" #492

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions drivers/net/ethernet/motorcomm/yt6801/fuxi-efuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,9 @@ bool fxgmac_read_mac_subsys_from_efuse(struct fxgmac_pdata *pdata, u8 *mac_addr,
bool fxgmac_write_mac_subsys_to_efuse(struct fxgmac_pdata *pdata, u8 *mac_addr,
u32 *subsys, u32 *revid)
{
#ifdef DBG
u32 machr = 0, maclr = 0;
#endif
u32 pcie_cfg_ctrl = PCIE_CFG_CTRL_DEFAULT_VAL;
u32 machr = 0, maclr = 0, pcie_cfg_ctrl = PCIE_CFG_CTRL_DEFAULT_VAL;
bool succeed = true;
if (mac_addr) {
#ifdef DBG
machr = readreg(pdata->pAdapter,
pdata->base_mem + MACA0HR_FROM_EFUSE);
maclr = readreg(pdata->pAdapter,
Expand All @@ -431,7 +427,7 @@ bool fxgmac_write_mac_subsys_to_efuse(struct fxgmac_pdata *pdata, u8 *mac_addr,
(machr >> 8) & 0xFF, machr & 0xFF, (maclr >> 24) & 0xFF,
(maclr >> 16) & 0xFF, (maclr >> 8) & 0xFF,
maclr & 0xFF);
#endif

if (!fxgmac_write_patch_to_efuse(pdata, MACA0HR_FROM_EFUSE,
(((u32)mac_addr[0]) << 8) |
mac_addr[1])) {
Expand Down Expand Up @@ -477,13 +473,10 @@ bool fxgmac_write_mac_subsys_to_efuse(struct fxgmac_pdata *pdata, u8 *mac_addr,

bool fxgmac_write_mac_addr_to_efuse(struct fxgmac_pdata *pdata, u8 *mac_addr)
{
#ifdef DBG
u32 machr = 0, maclr = 0;
#endif
bool succeed = true;

if (mac_addr) {
#ifdef DBG
machr = readreg(pdata->pAdapter,
pdata->base_mem + MACA0HR_FROM_EFUSE);
maclr = readreg(pdata->pAdapter,
Expand All @@ -492,7 +485,7 @@ bool fxgmac_write_mac_addr_to_efuse(struct fxgmac_pdata *pdata, u8 *mac_addr)
(machr >> 8) & 0xFF, machr & 0xFF, (maclr >> 24) & 0xFF,
(maclr >> 16) & 0xFF, (maclr >> 8) & 0xFF,
maclr & 0xFF);
#endif

if (!fxgmac_write_patch_to_efuse(pdata, MACA0HR_FROM_EFUSE,
(((u32)mac_addr[0]) << 8) |
mac_addr[1])) {
Expand Down
59 changes: 33 additions & 26 deletions drivers/net/ethernet/motorcomm/yt6801/fuxi-gmac-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static void fxgmac_read_mac_addr(struct fxgmac_pdata *pdata)
struct net_device *netdev = pdata->netdev;
struct fxgmac_hw_ops *hw_ops = &pdata->hw_ops;

/* DPRINTK("read mac from eFuse\n"); */
DPRINTK("read mac from eFuse\n");

/* if efuse have mac addr, use it.if not, use static mac address. */
hw_ops->read_mac_subsys_from_efuse(pdata, pdata->mac_addr, NULL, NULL);
Expand All @@ -35,10 +35,10 @@ static void fxgmac_default_config(struct fxgmac_pdata *pdata)
{
pdata->tx_osp_mode = DMA_OSP_ENABLE;
pdata->tx_sf_mode = MTL_TSF_ENABLE;
pdata->rx_sf_mode = MTL_RSF_ENABLE; /* MTL_RSF_DISABLE 20210514 */
pdata->rx_sf_mode = MTL_RSF_DISABLE; /* MTL_RSF_DISABLE 20210514 */
pdata->pblx8 = DMA_PBL_X8_ENABLE; /* DMA_PBL_X8_ENABLE 20210514 */
pdata->tx_pbl = DMA_PBL_16;
pdata->rx_pbl = DMA_PBL_4; /* DMA_PBL_32 20210514 */
pdata->tx_pbl = DMA_PBL_32;
pdata->rx_pbl = DMA_PBL_32; /* DMA_PBL_32 20210514 */
pdata->tx_threshold = MTL_TX_THRESHOLD_128;
pdata->rx_threshold = MTL_RX_THRESHOLD_128;
pdata->tx_pause = 1;
Expand Down Expand Up @@ -66,16 +66,16 @@ static void fxgmac_default_config(struct fxgmac_pdata *pdata)
strscpy(pdata->drv_name, FXGMAC_DRV_NAME, sizeof(pdata->drv_name));
strscpy(pdata->drv_ver, FXGMAC_DRV_VERSION, sizeof(pdata->drv_ver));

dev_info(pdata->dev, "FXGMAC_DRV_NAME:%s, FXGMAC_DRV_VERSION:%s\n",
FXGMAC_DRV_NAME, FXGMAC_DRV_VERSION);
printk("FXGMAC_DRV_NAME:%s, FXGMAC_DRV_VERSION:%s\n", FXGMAC_DRV_NAME,
FXGMAC_DRV_VERSION);
}

static void fxgmac_init_all_ops(struct fxgmac_pdata *pdata)
{
fxgmac_init_desc_ops(&pdata->desc_ops);
fxgmac_init_hw_ops(&pdata->hw_ops);

/* DPRINTK("register desc_ops and hw ops\n"); */
DPRINTK("register desc_ops and hw ops\n");
}

int fxgmac_init(struct fxgmac_pdata *pdata, bool save_private_reg)
Expand Down Expand Up @@ -152,11 +152,17 @@ int fxgmac_init(struct fxgmac_pdata *pdata, bool save_private_reg)
pdata->hw_feat.tx_q_cnt);
pdata->tx_q_count = pdata->tx_ring_count;

#if !(FXGMAC_NUM_OF_TX_Q_USED)
ret = netif_set_real_num_tx_queues(netdev, pdata->tx_q_count);
#else
ret = netif_set_real_num_tx_queues(
netdev, FXGMAC_NUM_OF_TX_Q_USED /*pdata->tx_q_count*/);
#endif

DPRINTK("num_online_cpus:%u, tx_ch_cnt:%u, tx_q_cnt:%u, tx_ring_count:%u\n",
num_online_cpus(), pdata->hw_feat.tx_ch_cnt,
pdata->hw_feat.tx_q_cnt, pdata->tx_ring_count);

if (ret) {
dev_err(pdata->dev, "error setting real tx queue count\n");
return ret;
Expand Down Expand Up @@ -186,7 +192,7 @@ int fxgmac_init(struct fxgmac_pdata *pdata, bool save_private_reg)
netif_get_num_default_rss_queues(), pdata->hw_feat.rx_ch_cnt,
pdata->hw_feat.rx_q_cnt, pdata->rx_ring_count);
DPRINTK("channel_count:%u, netdev tx channel_num=%u\n",
pdata->channel_count, netdev->real_num_tx_queues);
pdata->channel_count, netdev->num_tx_queues);

/* Initialize RSS hash key and lookup table */
#if FXGMAC_RSS_HASH_KEY_LINUX
Expand Down Expand Up @@ -300,8 +306,6 @@ int fxgmac_init(struct fxgmac_pdata *pdata, bool save_private_reg)
pdata->rx_usecs = FXGMAC_INIT_DMA_RX_USECS;
pdata->rx_frames = FXGMAC_INIT_DMA_RX_FRAMES;

mutex_init(&pdata->expansion.mutex);

DPRINTK("fxgmac_init callout, ok.\n");

return 0;
Expand All @@ -316,14 +320,14 @@ static void fxgmac_init_interrupt_scheme(struct fxgmac_pdata *pdata)
* otherwise, just roll back to legacy
*/
vectors = num_online_cpus();
DPRINTK("num of cpu=%d\n", vectors);
if (vectors >= FXGMAC_MAX_DMA_CHANNELS) {
/* 0-3 for rx, 4 for tx, 5 for phy */
req_vectors = FXGMAC_MSIX_INT_NUMS;
pdata->expansion.msix_entries = kcalloc(
req_vectors, sizeof(struct msix_entry), GFP_KERNEL);
if (!pdata->expansion.msix_entries) {
dev_err(pdata->dev, "MSIx, kcalloc err for msix entries, \
rollback to MSI\n");
DPRINTK("MSIx, kcalloc err for msix entries, rollback to MSI..\n");
goto enable_msi_interrupt;
} else {
for (i = 0; i < req_vectors; i++)
Expand All @@ -333,14 +337,14 @@ static void fxgmac_init_interrupt_scheme(struct fxgmac_pdata *pdata)
pdata->pdev, pdata->expansion.msix_entries,
req_vectors, req_vectors);
if (rc < 0) {
dev_err(pdata->dev, "enable MSIx failed,%d.\n", rc);
DPRINTK("enable MSIx failed,%d.\n", rc);
req_vectors = 0; /* indicate failure */
} else {
req_vectors = rc;
}

if (req_vectors >= FXGMAC_MAX_DMA_CHANNELS_PLUS_1TX) {
dev_info(pdata->dev, "enable MSIx ok, cpu=%d,vectors=%d.\n",
DPRINTK("enable MSIx ok, cpu=%d, vectors=%d.\n",
vectors, req_vectors);
pdata->expansion.int_flags =
FXGMAC_SET_REG_BITS(
Expand All @@ -349,22 +353,21 @@ static void fxgmac_init_interrupt_scheme(struct fxgmac_pdata *pdata)
FXGMAC_FLAG_INTERRUPT_LEN,
FXGMAC_FLAG_MSIX_ENABLED);
pdata->per_channel_irq = 1;
pdata->expansion.misc_irq =
pdata->expansion.phy_irq =
pdata->expansion
.msix_entries[MSI_ID_PHY_OTHER]
.vector;
return;
} else if (req_vectors) {
dev_err(pdata->dev, "enable MSIx with only %d vector, \
+ while we need %d, rollback to MSI.\n",
+ req_vectors, vectors);
DPRINTK("enable MSIx with only %d vector, while we need %d, rollback to MSI.\n",
req_vectors, vectors);
/* roll back to msi */
pci_disable_msix(pdata->pdev);
kfree(pdata->expansion.msix_entries);
pdata->expansion.msix_entries = NULL;
req_vectors = 0;
} else {
dev_err(pdata->dev, "enable MSIx failure and clear msix entries.\n");
DPRINTK("enable MSIx failure and clear msix entries.\n");
/* roll back to msi */
kfree(pdata->expansion.msix_entries);
pdata->expansion.msix_entries = NULL;
Expand All @@ -379,13 +382,13 @@ static void fxgmac_init_interrupt_scheme(struct fxgmac_pdata *pdata)
pdata->expansion.int_flags = FXGMAC_SET_REG_BITS(
pdata->expansion.int_flags, FXGMAC_FLAG_INTERRUPT_POS,
FXGMAC_FLAG_INTERRUPT_LEN, FXGMAC_FLAG_LEGACY_ENABLED);
dev_err(pdata->dev, "dev_err MSI failure, rollback to LEGACY.\n");
DPRINTK("enable MSI failure, rollback to LEGACY.\n");
} else {
pdata->expansion.int_flags = FXGMAC_SET_REG_BITS(
pdata->expansion.int_flags, FXGMAC_FLAG_INTERRUPT_POS,
FXGMAC_FLAG_INTERRUPT_LEN, FXGMAC_FLAG_MSI_ENABLED);
pdata->dev_irq = pdata->pdev->irq;
dev_info(pdata->dev, "enable MSI ok, cpu=%d, irq=%d.\n", vectors, pdata->pdev->irq);
DPRINTK("enable MSI ok, irq=%d.\n", pdata->pdev->irq);
}
#else
pdata = pdata;
Expand Down Expand Up @@ -414,16 +417,20 @@ int fxgmac_drv_probe(struct device *dev, struct fxgmac_resources *res)
pdata->netdev = netdev;

pdata->dev_irq = res->irq;
pdata->msg_enable = NETIF_MSG_DRV;
pdata->expansion.dev_state = FXGMAC_DEV_PROBE;

/* default to legacy interrupt */
pdata->expansion.int_flags = FXGMAC_SET_REG_BITS(
pdata->expansion.int_flags, FXGMAC_FLAG_INTERRUPT_POS,
FXGMAC_FLAG_INTERRUPT_LEN, FXGMAC_FLAG_LEGACY_ENABLED);
pdata->expansion.misc_irq = pdata->dev_irq;
pdata->expansion.phy_irq = pdata->dev_irq;

fxgmac_init_interrupt_scheme(pdata);

pdata->expansion.current_state = CURRENT_STATE_INIT;

pdata->msg_enable = NETIF_MSG_DRV;
DPRINTK("netif msg_enable init to %08x\n", pdata->msg_enable);

pdata->mac_regs = res->addr;
pdata->base_mem = res->addr;
pdata->mac_regs = pdata->mac_regs + FUXI_MAC_REGS_OFFSET;
Expand All @@ -444,7 +451,7 @@ int fxgmac_drv_probe(struct device *dev, struct fxgmac_resources *res)
}
if (netif_msg_drv(pdata))
DPRINTK("fxgamc_drv_prob callout, netdev num_tx_q=%u\n",
netdev->real_num_tx_queues);
netdev->num_tx_queues);

#ifdef HAVE_FXGMAC_DEBUG_FS
fxgmac_dbg_init(pdata);
Expand Down Expand Up @@ -708,7 +715,7 @@ void fxgmac_get_all_hw_features(struct fxgmac_pdata *pdata)
hw_feat->tc_cnt++;

hw_feat->hwfr3 = mac_hfr3;
/* DPRINTK("HWFR3: %u\n", mac_hfr3); */
DPRINTK("HWFR3: %u\n", mac_hfr3);
}

void fxgmac_print_all_hw_features(struct fxgmac_pdata *pdata)
Expand Down
42 changes: 14 additions & 28 deletions drivers/net/ethernet/motorcomm/yt6801/fuxi-gmac-debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,8 @@ long fxgmac_dbg_netdev_ops_ioctl(struct file *file, unsigned int cmd,
memcpy(&ex_data, data, sizeof(CMD_DATA));
ret = hw_ops->read_efuse_data(pdata, ex_data.val0,
&ex_data.val1);
/*
* DPRINTK("FXGMAC_EFUSE_READ_REGIONABC, address = 0x%x, val = 0x%x\n",
* ex_data.val0,
* ex_data.val1);
*/
DPRINTK("FXGMAC_EFUSE_READ_REGIONABC, address = 0x%x, val = 0x%x\n",
ex_data.val0, ex_data.val1);
if (ret) {
memcpy(data, &ex_data, sizeof(CMD_DATA));
out_total_size =
Expand All @@ -468,11 +465,8 @@ long fxgmac_dbg_netdev_ops_ioctl(struct file *file, unsigned int cmd,

case FXGMAC_EFUSE_WRITE_PATCH_REG:
memcpy(&ex_data, data, sizeof(CMD_DATA));
/*
* DPRINTK("FXGMAC_EFUSE_WRITE_PATCH_REG, address = 0x%x, val = 0x%x\n",
* ex_data.val0,
* ex_data.val1);
*/
DPRINTK("FXGMAC_EFUSE_WRITE_PATCH_REG, address = 0x%x, val = 0x%x\n",
ex_data.val0, ex_data.val1);
ret = hw_ops->write_patch_to_efuse(pdata, ex_data.val0,
ex_data.val1);
break;
Expand All @@ -481,10 +475,8 @@ long fxgmac_dbg_netdev_ops_ioctl(struct file *file, unsigned int cmd,
memcpy(&ex_data, data, sizeof(CMD_DATA));
ret = hw_ops->read_patch_from_efuse(pdata, ex_data.val0,
&ex_data.val1);
/*
* DPRINTK("FXGMAC_EFUSE_READ_PATCH_REG, address = 0x%x, val = 0x%x\n",
* ex_data.val0, ex_data.val1);
*/
DPRINTK("FXGMAC_EFUSE_READ_PATCH_REG, address = 0x%x, val = 0x%x\n",
ex_data.val0, ex_data.val1);
if (ret) {
memcpy(data, &ex_data, sizeof(CMD_DATA));
out_total_size =
Expand All @@ -500,21 +492,17 @@ long fxgmac_dbg_netdev_ops_ioctl(struct file *file, unsigned int cmd,
ret = hw_ops->write_patch_to_efuse_per_index(
pdata, ex_data.val0, ex_data.val1,
ex_data.val2);
/*
* DPRINTK("FXGMAC_EFUSE_WRITE_PATCH_PER_INDEX, index = %d, address = 0x%x, val = 0x%x\n",
* ex_data.val0, ex_data.val1, ex_data.val2);
*/
DPRINTK("FXGMAC_EFUSE_WRITE_PATCH_PER_INDEX, index = %d, address = 0x%x, val = 0x%x\n",
ex_data.val0, ex_data.val1, ex_data.val2);
break;

case FXGMAC_EFUSE_READ_PATCH_PER_INDEX:
memcpy(&ex_data, data, sizeof(CMD_DATA));
ret = hw_ops->read_patch_from_efuse_per_index(
pdata, ex_data.val0, &ex_data.val1,
&ex_data.val2);
/*
* DPRINTK("FXGMAC_EFUSE_READ_PATCH_PER_INDEX, address = 0x%x, val = 0x%x\n",
* ex_data.val1, ex_data.val2);
*/
DPRINTK("FXGMAC_EFUSE_READ_PATCH_PER_INDEX, address = 0x%x, val = 0x%x\n",
ex_data.val1, ex_data.val2);
if (ret) {
memcpy(data, &ex_data, sizeof(CMD_DATA));
out_total_size =
Expand Down Expand Up @@ -577,7 +565,7 @@ long fxgmac_dbg_netdev_ops_ioctl(struct file *file, unsigned int cmd,
pdata, NULL, &ex_data.val0, NULL);
break;

case FXGMAC_GET_REG:
case FXGMAC_GET_GMAC_REG:
memcpy(&ex_data, data, sizeof(CMD_DATA));
ex_data.val1 = hw_ops->get_gmac_register(
pdata, (u8 *)(pdata->mac_regs + ex_data.val0));
Expand All @@ -588,7 +576,7 @@ long fxgmac_dbg_netdev_ops_ioctl(struct file *file, unsigned int cmd,
goto err;
break;

case FXGMAC_SET_REG:
case FXGMAC_SET_GMAC_REG:
memcpy(&ex_data, data, sizeof(CMD_DATA));
regval = hw_ops->set_gmac_register(
pdata, (u8 *)(pdata->mac_regs + ex_data.val0),
Expand Down Expand Up @@ -709,7 +697,7 @@ static struct file_operations fxgmac_dbg_netdev_ops_fops = {

/**
* fxgmac_dbg_adapter_init - setup the debugfs directory for the adapter
* @pdata: board private structure
* @adapter: the adapter that is starting up
**/
void fxgmac_dbg_adapter_init(struct fxgmac_pdata *pdata)
{
Expand All @@ -731,7 +719,7 @@ void fxgmac_dbg_adapter_init(struct fxgmac_pdata *pdata)

/**
* fxgmac_dbg_adapter_exit - clear out the adapter's debugfs entries
* @pdata: board private structure
* @adapter: board private structure
**/
void fxgmac_dbg_adapter_exit(struct fxgmac_pdata *pdata)
{
Expand All @@ -742,7 +730,6 @@ void fxgmac_dbg_adapter_exit(struct fxgmac_pdata *pdata)

/**
* fxgmac_dbg_init - start up debugfs for the driver
* @pdata: board private structure
**/
void fxgmac_dbg_init(struct fxgmac_pdata *pdata)
{
Expand Down Expand Up @@ -790,7 +777,6 @@ void fxgmac_dbg_init(struct fxgmac_pdata *pdata)

/**
* fxgmac_dbg_exit - clean out the driver's debugfs entries
* @pdata: board private structure
**/
void fxgmac_dbg_exit(struct fxgmac_pdata *pdata)
{
Expand Down
Loading
Loading