Commit 48927142 authored by David S. Miller's avatar David S. Miller

Merge branch 'lan743x-enhancements'

Raju Lakkaraju says:

====================
net: lan743x: PCI11010 / PCI11414 devices Enhancements

This patch series adds support of the Ethernet function of the PCI11010 / PCI11414 devices to the LAN743x driver.
The PCI1xxxx family of devices consists of a PCIe switch with a variety of embedded PCI endpoints on its downstream ports.
The PCI11010 / PCI11414 devices include an Ethernet 10/100/1000/2500 function as one of those embedded endpoints.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 1f52d7b6 a2ab95a3
......@@ -18,6 +18,51 @@
#include "lan743x_main.h"
#include "lan743x_ethtool.h"
#define MMD_ACCESS_ADDRESS 0
#define MMD_ACCESS_WRITE 1
#define MMD_ACCESS_READ 2
#define MMD_ACCESS_READ_INC 3
static void pci11x1x_strap_get_status(struct lan743x_adapter *adapter)
{
u32 chip_rev;
u32 strap;
strap = lan743x_csr_read(adapter, STRAP_READ);
if (strap & STRAP_READ_USE_SGMII_EN_) {
if (strap & STRAP_READ_SGMII_EN_)
adapter->is_sgmii_en = true;
else
adapter->is_sgmii_en = false;
netif_dbg(adapter, drv, adapter->netdev,
"STRAP_READ: 0x%08X\n", strap);
} else {
chip_rev = lan743x_csr_read(adapter, FPGA_REV);
if (chip_rev) {
if (chip_rev & FPGA_SGMII_OP)
adapter->is_sgmii_en = true;
else
adapter->is_sgmii_en = false;
netif_dbg(adapter, drv, adapter->netdev,
"FPGA_REV: 0x%08X\n", chip_rev);
} else {
adapter->is_sgmii_en = false;
}
}
}
static bool is_pci11x1x_chip(struct lan743x_adapter *adapter)
{
struct lan743x_csr *csr = &adapter->csr;
u32 id_rev = csr->id_rev;
if (((id_rev & 0xFFFF0000) == ID_REV_ID_A011_) ||
((id_rev & 0xFFFF0000) == ID_REV_ID_A041_)) {
return true;
}
return false;
}
static void lan743x_pci_cleanup(struct lan743x_adapter *adapter)
{
pci_release_selected_regions(adapter->pdev,
......@@ -250,7 +295,7 @@ static void lan743x_intr_shared_isr(void *context, u32 int_sts, u32 flags)
}
}
if (int_sts & INT_BIT_ALL_TX_) {
for (channel = 0; channel < LAN743X_USED_TX_CHANNELS;
for (channel = 0; channel < adapter->used_tx_channels;
channel++) {
u32 int_bit = INT_BIT_DMA_TX_(channel);
......@@ -410,7 +455,7 @@ static u32 lan743x_intr_get_vector_flags(struct lan743x_adapter *adapter,
{
int index;
for (index = 0; index < LAN743X_MAX_VECTOR_COUNT; index++) {
for (index = 0; index < adapter->max_vector_count; index++) {
if (adapter->intr.vector_list[index].int_mask & int_mask)
return adapter->intr.vector_list[index].flags;
}
......@@ -423,9 +468,12 @@ static void lan743x_intr_close(struct lan743x_adapter *adapter)
int index = 0;
lan743x_csr_write(adapter, INT_EN_CLR, INT_BIT_MAS_);
lan743x_csr_write(adapter, INT_VEC_EN_CLR, 0x000000FF);
if (adapter->is_pci11x1x)
lan743x_csr_write(adapter, INT_VEC_EN_CLR, 0x0000FFFF);
else
lan743x_csr_write(adapter, INT_VEC_EN_CLR, 0x000000FF);
for (index = 0; index < LAN743X_MAX_VECTOR_COUNT; index++) {
for (index = 0; index < intr->number_of_vectors; index++) {
if (intr->flags & INTR_FLAG_IRQ_REQUESTED(index)) {
lan743x_intr_unregister_isr(adapter, index);
intr->flags &= ~INTR_FLAG_IRQ_REQUESTED(index);
......@@ -445,9 +493,11 @@ static void lan743x_intr_close(struct lan743x_adapter *adapter)
static int lan743x_intr_open(struct lan743x_adapter *adapter)
{
struct msix_entry msix_entries[LAN743X_MAX_VECTOR_COUNT];
struct msix_entry msix_entries[PCI11X1X_MAX_VECTOR_COUNT];
struct lan743x_intr *intr = &adapter->intr;
unsigned int used_tx_channels;
u32 int_vec_en_auto_clr = 0;
u8 max_vector_count;
u32 int_vec_map0 = 0;
u32 int_vec_map1 = 0;
int ret = -ENODEV;
......@@ -457,13 +507,15 @@ static int lan743x_intr_open(struct lan743x_adapter *adapter)
intr->number_of_vectors = 0;
/* Try to set up MSIX interrupts */
max_vector_count = adapter->max_vector_count;
memset(&msix_entries[0], 0,
sizeof(struct msix_entry) * LAN743X_MAX_VECTOR_COUNT);
for (index = 0; index < LAN743X_MAX_VECTOR_COUNT; index++)
sizeof(struct msix_entry) * max_vector_count);
for (index = 0; index < max_vector_count; index++)
msix_entries[index].entry = index;
used_tx_channels = adapter->used_tx_channels;
ret = pci_enable_msix_range(adapter->pdev,
msix_entries, 1,
1 + LAN743X_USED_TX_CHANNELS +
1 + used_tx_channels +
LAN743X_USED_RX_CHANNELS);
if (ret > 0) {
......@@ -556,8 +608,15 @@ static int lan743x_intr_open(struct lan743x_adapter *adapter)
lan743x_csr_write(adapter, INT_MOD_CFG5, LAN743X_INT_MOD);
lan743x_csr_write(adapter, INT_MOD_CFG6, LAN743X_INT_MOD);
lan743x_csr_write(adapter, INT_MOD_CFG7, LAN743X_INT_MOD);
lan743x_csr_write(adapter, INT_MOD_MAP0, 0x00005432);
lan743x_csr_write(adapter, INT_MOD_MAP1, 0x00000001);
if (adapter->is_pci11x1x) {
lan743x_csr_write(adapter, INT_MOD_CFG8, LAN743X_INT_MOD);
lan743x_csr_write(adapter, INT_MOD_CFG9, LAN743X_INT_MOD);
lan743x_csr_write(adapter, INT_MOD_MAP0, 0x00007654);
lan743x_csr_write(adapter, INT_MOD_MAP1, 0x00003210);
} else {
lan743x_csr_write(adapter, INT_MOD_MAP0, 0x00005432);
lan743x_csr_write(adapter, INT_MOD_MAP1, 0x00000001);
}
lan743x_csr_write(adapter, INT_MOD_MAP2, 0x00FFFFFF);
}
......@@ -570,8 +629,8 @@ static int lan743x_intr_open(struct lan743x_adapter *adapter)
if (intr->number_of_vectors > 1) {
int number_of_tx_vectors = intr->number_of_vectors - 1;
if (number_of_tx_vectors > LAN743X_USED_TX_CHANNELS)
number_of_tx_vectors = LAN743X_USED_TX_CHANNELS;
if (number_of_tx_vectors > used_tx_channels)
number_of_tx_vectors = used_tx_channels;
flags = LAN743X_VECTOR_FLAG_SOURCE_STATUS_READ |
LAN743X_VECTOR_FLAG_SOURCE_STATUS_W2C |
LAN743X_VECTOR_FLAG_SOURCE_ENABLE_CHECK |
......@@ -609,9 +668,9 @@ static int lan743x_intr_open(struct lan743x_adapter *adapter)
INT_VEC_EN_(vector));
}
}
if ((intr->number_of_vectors - LAN743X_USED_TX_CHANNELS) > 1) {
if ((intr->number_of_vectors - used_tx_channels) > 1) {
int number_of_rx_vectors = intr->number_of_vectors -
LAN743X_USED_TX_CHANNELS - 1;
used_tx_channels - 1;
if (number_of_rx_vectors > LAN743X_USED_RX_CHANNELS)
number_of_rx_vectors = LAN743X_USED_RX_CHANNELS;
......@@ -632,7 +691,7 @@ static int lan743x_intr_open(struct lan743x_adapter *adapter)
LAN743X_VECTOR_FLAG_SOURCE_STATUS_AUTO_CLEAR;
}
for (index = 0; index < number_of_rx_vectors; index++) {
int vector = index + 1 + LAN743X_USED_TX_CHANNELS;
int vector = index + 1 + used_tx_channels;
u32 int_bit = INT_BIT_DMA_RX_(index);
/* map RX interrupt to vector */
......@@ -760,6 +819,96 @@ static int lan743x_mdiobus_write(struct mii_bus *bus,
return ret;
}
static u32 lan743x_mac_mmd_access(int id, int index, int op)
{
u16 dev_addr;
u32 ret;
dev_addr = (index >> 16) & 0x1f;
ret = (id << MAC_MII_ACC_PHY_ADDR_SHIFT_) &
MAC_MII_ACC_PHY_ADDR_MASK_;
ret |= (dev_addr << MAC_MII_ACC_MIIMMD_SHIFT_) &
MAC_MII_ACC_MIIMMD_MASK_;
if (op == MMD_ACCESS_WRITE)
ret |= MAC_MII_ACC_MIICMD_WRITE_;
else if (op == MMD_ACCESS_READ)
ret |= MAC_MII_ACC_MIICMD_READ_;
else if (op == MMD_ACCESS_READ_INC)
ret |= MAC_MII_ACC_MIICMD_READ_INC_;
else
ret |= MAC_MII_ACC_MIICMD_ADDR_;
ret |= (MAC_MII_ACC_MII_BUSY_ | MAC_MII_ACC_MIICL45_);
return ret;
}
static int lan743x_mdiobus_c45_read(struct mii_bus *bus, int phy_id, int index)
{
struct lan743x_adapter *adapter = bus->priv;
u32 mmd_access;
int ret;
/* comfirm MII not busy */
ret = lan743x_mac_mii_wait_till_not_busy(adapter);
if (ret < 0)
return ret;
if (index & MII_ADDR_C45) {
/* Load Register Address */
lan743x_csr_write(adapter, MAC_MII_DATA, (u32)(index & 0xffff));
mmd_access = lan743x_mac_mmd_access(phy_id, index,
MMD_ACCESS_ADDRESS);
lan743x_csr_write(adapter, MAC_MII_ACC, mmd_access);
ret = lan743x_mac_mii_wait_till_not_busy(adapter);
if (ret < 0)
return ret;
/* Read Data */
mmd_access = lan743x_mac_mmd_access(phy_id, index,
MMD_ACCESS_READ);
lan743x_csr_write(adapter, MAC_MII_ACC, mmd_access);
ret = lan743x_mac_mii_wait_till_not_busy(adapter);
if (ret < 0)
return ret;
ret = lan743x_csr_read(adapter, MAC_MII_DATA);
return (int)(ret & 0xFFFF);
}
ret = lan743x_mdiobus_read(bus, phy_id, index);
return ret;
}
static int lan743x_mdiobus_c45_write(struct mii_bus *bus,
int phy_id, int index, u16 regval)
{
struct lan743x_adapter *adapter = bus->priv;
u32 mmd_access;
int ret;
/* confirm MII not busy */
ret = lan743x_mac_mii_wait_till_not_busy(adapter);
if (ret < 0)
return ret;
if (index & MII_ADDR_C45) {
/* Load Register Address */
lan743x_csr_write(adapter, MAC_MII_DATA, (u32)(index & 0xffff));
mmd_access = lan743x_mac_mmd_access(phy_id, index,
MMD_ACCESS_ADDRESS);
lan743x_csr_write(adapter, MAC_MII_ACC, mmd_access);
ret = lan743x_mac_mii_wait_till_not_busy(adapter);
if (ret < 0)
return ret;
/* Write Data */
lan743x_csr_write(adapter, MAC_MII_DATA, (u32)regval);
mmd_access = lan743x_mac_mmd_access(phy_id, index,
MMD_ACCESS_WRITE);
lan743x_csr_write(adapter, MAC_MII_ACC, mmd_access);
ret = lan743x_mac_mii_wait_till_not_busy(adapter);
} else {
ret = lan743x_mdiobus_write(bus, phy_id, index, regval);
}
return ret;
}
static void lan743x_mac_set_address(struct lan743x_adapter *adapter,
u8 *addr)
{
......@@ -2491,7 +2640,8 @@ static int lan743x_netdev_close(struct net_device *netdev)
struct lan743x_adapter *adapter = netdev_priv(netdev);
int index;
lan743x_tx_close(&adapter->tx[0]);
for (index = 0; index < adapter->used_tx_channels; index++)
lan743x_tx_close(&adapter->tx[index]);
for (index = 0; index < LAN743X_USED_RX_CHANNELS; index++)
lan743x_rx_close(&adapter->rx[index]);
......@@ -2537,12 +2687,19 @@ static int lan743x_netdev_open(struct net_device *netdev)
goto close_rx;
}
ret = lan743x_tx_open(&adapter->tx[0]);
if (ret)
goto close_rx;
for (index = 0; index < adapter->used_tx_channels; index++) {
ret = lan743x_tx_open(&adapter->tx[index]);
if (ret)
goto close_tx;
}
return 0;
close_tx:
for (index = 0; index < adapter->used_tx_channels; index++) {
if (adapter->tx[index].ring_cpu_ptr)
lan743x_tx_close(&adapter->tx[index]);
}
close_rx:
for (index = 0; index < LAN743X_USED_RX_CHANNELS; index++) {
if (adapter->rx[index].ring_cpu_ptr)
......@@ -2569,8 +2726,12 @@ static netdev_tx_t lan743x_netdev_xmit_frame(struct sk_buff *skb,
struct net_device *netdev)
{
struct lan743x_adapter *adapter = netdev_priv(netdev);
u8 ch = 0;
return lan743x_tx_xmit_frame(&adapter->tx[0], skb);
if (adapter->is_pci11x1x)
ch = skb->queue_mapping % PCI11X1X_USED_TX_CHANNELS;
return lan743x_tx_xmit_frame(&adapter->tx[ch], skb);
}
static int lan743x_netdev_ioctl(struct net_device *netdev,
......@@ -2701,6 +2862,18 @@ static int lan743x_hardware_init(struct lan743x_adapter *adapter,
int index;
int ret;
adapter->is_pci11x1x = is_pci11x1x_chip(adapter);
if (adapter->is_pci11x1x) {
adapter->max_tx_channels = PCI11X1X_MAX_TX_CHANNELS;
adapter->used_tx_channels = PCI11X1X_USED_TX_CHANNELS;
adapter->max_vector_count = PCI11X1X_MAX_VECTOR_COUNT;
pci11x1x_strap_get_status(adapter);
} else {
adapter->max_tx_channels = LAN743X_MAX_TX_CHANNELS;
adapter->used_tx_channels = LAN743X_USED_TX_CHANNELS;
adapter->max_vector_count = LAN743X_MAX_VECTOR_COUNT;
}
adapter->intr.irq = adapter->pdev->irq;
lan743x_csr_write(adapter, INT_EN_CLR, 0xFFFFFFFF);
......@@ -2731,15 +2904,19 @@ static int lan743x_hardware_init(struct lan743x_adapter *adapter,
adapter->rx[index].channel_number = index;
}
tx = &adapter->tx[0];
tx->adapter = adapter;
tx->channel_number = 0;
spin_lock_init(&tx->ring_lock);
for (index = 0; index < adapter->used_tx_channels; index++) {
tx = &adapter->tx[index];
tx->adapter = adapter;
tx->channel_number = index;
spin_lock_init(&tx->ring_lock);
}
return 0;
}
static int lan743x_mdiobus_init(struct lan743x_adapter *adapter)
{
u32 sgmii_ctl;
int ret;
adapter->mdiobus = devm_mdiobus_alloc(&adapter->pdev->dev);
......@@ -2749,9 +2926,35 @@ static int lan743x_mdiobus_init(struct lan743x_adapter *adapter)
}
adapter->mdiobus->priv = (void *)adapter;
adapter->mdiobus->read = lan743x_mdiobus_read;
adapter->mdiobus->write = lan743x_mdiobus_write;
adapter->mdiobus->name = "lan743x-mdiobus";
if (adapter->is_pci11x1x) {
if (adapter->is_sgmii_en) {
sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL);
sgmii_ctl |= SGMII_CTL_SGMII_ENABLE_;
sgmii_ctl &= ~SGMII_CTL_SGMII_POWER_DN_;
lan743x_csr_write(adapter, SGMII_CTL, sgmii_ctl);
netif_dbg(adapter, drv, adapter->netdev,
"SGMII operation\n");
} else {
sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL);
sgmii_ctl &= ~SGMII_CTL_SGMII_ENABLE_;
sgmii_ctl |= SGMII_CTL_SGMII_POWER_DN_;
lan743x_csr_write(adapter, SGMII_CTL, sgmii_ctl);
netif_dbg(adapter, drv, adapter->netdev,
"(R)GMII operation\n");
}
adapter->mdiobus->probe_capabilities = MDIOBUS_C22_C45;
adapter->mdiobus->read = lan743x_mdiobus_c45_read;
adapter->mdiobus->write = lan743x_mdiobus_c45_write;
adapter->mdiobus->name = "lan743x-mdiobus-c45";
netif_dbg(adapter, drv, adapter->netdev, "lan743x-mdiobus-c45\n");
} else {
adapter->mdiobus->read = lan743x_mdiobus_read;
adapter->mdiobus->write = lan743x_mdiobus_write;
adapter->mdiobus->name = "lan743x-mdiobus";
netif_dbg(adapter, drv, adapter->netdev, "lan743x-mdiobus\n");
}
snprintf(adapter->mdiobus->id, MII_BUS_ID_SIZE,
"pci-%s", pci_name(adapter->pdev));
......@@ -2786,8 +2989,17 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev,
struct net_device *netdev = NULL;
int ret = -ENODEV;
netdev = devm_alloc_etherdev(&pdev->dev,
sizeof(struct lan743x_adapter));
if (id->device == PCI_DEVICE_ID_SMSC_A011 ||
id->device == PCI_DEVICE_ID_SMSC_A041) {
netdev = devm_alloc_etherdev_mqs(&pdev->dev,
sizeof(struct lan743x_adapter),
PCI11X1X_USED_TX_CHANNELS,
LAN743X_USED_RX_CHANNELS);
} else {
netdev = devm_alloc_etherdev(&pdev->dev,
sizeof(struct lan743x_adapter));
}
if (!netdev)
goto return_error;
......@@ -3056,6 +3268,8 @@ static const struct dev_pm_ops lan743x_pm_ops = {
static const struct pci_device_id lan743x_pcidev_tbl[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_SMSC, PCI_DEVICE_ID_SMSC_LAN7430) },
{ PCI_DEVICE(PCI_VENDOR_ID_SMSC, PCI_DEVICE_ID_SMSC_LAN7431) },
{ PCI_DEVICE(PCI_VENDOR_ID_SMSC, PCI_DEVICE_ID_SMSC_A011) },
{ PCI_DEVICE(PCI_VENDOR_ID_SMSC, PCI_DEVICE_ID_SMSC_A041) },
{ 0, }
};
......
......@@ -16,8 +16,13 @@
#define ID_REV_ID_MASK_ (0xFFFF0000)
#define ID_REV_ID_LAN7430_ (0x74300000)
#define ID_REV_ID_LAN7431_ (0x74310000)
#define ID_REV_IS_VALID_CHIP_ID_(id_rev) \
(((id_rev) & 0xFFF00000) == 0x74300000)
#define ID_REV_ID_LAN743X_ (0x74300000)
#define ID_REV_ID_A011_ (0xA0110000) // PCI11010
#define ID_REV_ID_A041_ (0xA0410000) // PCI11414
#define ID_REV_ID_A0X1_ (0xA0010000)
#define ID_REV_IS_VALID_CHIP_ID_(id_rev) \
((((id_rev) & 0xFFF00000) == ID_REV_ID_LAN743X_) || \
(((id_rev) & 0xFF0F0000) == ID_REV_ID_A0X1_))
#define ID_REV_CHIP_REV_MASK_ (0x0000FFFF)
#define ID_REV_CHIP_REV_A0_ (0x00000000)
#define ID_REV_CHIP_REV_B0_ (0x00000010)
......@@ -25,6 +30,17 @@
#define FPGA_REV (0x04)
#define FPGA_REV_GET_MINOR_(fpga_rev) (((fpga_rev) >> 8) & 0x000000FF)
#define FPGA_REV_GET_MAJOR_(fpga_rev) ((fpga_rev) & 0x000000FF)
#define FPGA_SGMII_OP BIT(24)
#define STRAP_READ (0x0C)
#define STRAP_READ_USE_SGMII_EN_ BIT(22)
#define STRAP_READ_SGMII_EN_ BIT(6)
#define STRAP_READ_SGMII_REFCLK_ BIT(5)
#define STRAP_READ_SGMII_2_5G_ BIT(4)
#define STRAP_READ_BASE_X_ BIT(3)
#define STRAP_READ_RGMII_TXC_DELAY_EN_ BIT(2)
#define STRAP_READ_RGMII_RXC_DELAY_EN_ BIT(1)
#define STRAP_READ_ADV_PM_DISABLE_ BIT(0)
#define HW_CFG (0x010)
#define HW_CFG_RELOAD_TYPE_ALL_ (0x00000FC0)
......@@ -135,6 +151,13 @@
#define MAC_RX_ADDRL (0x11C)
#define MAC_MII_ACC (0x120)
#define MAC_MII_ACC_MDC_CYCLE_SHIFT_ (16)
#define MAC_MII_ACC_MDC_CYCLE_MASK_ (0x00070000)
#define MAC_MII_ACC_MDC_CYCLE_2_5MHZ_ (0)
#define MAC_MII_ACC_MDC_CYCLE_5MHZ_ (1)
#define MAC_MII_ACC_MDC_CYCLE_12_5MHZ_ (2)
#define MAC_MII_ACC_MDC_CYCLE_25MHZ_ (3)
#define MAC_MII_ACC_MDC_CYCLE_1_25MHZ_ (4)
#define MAC_MII_ACC_PHY_ADDR_SHIFT_ (11)
#define MAC_MII_ACC_PHY_ADDR_MASK_ (0x0000F800)
#define MAC_MII_ACC_MIIRINDA_SHIFT_ (6)
......@@ -143,6 +166,15 @@
#define MAC_MII_ACC_MII_WRITE_ (0x00000002)
#define MAC_MII_ACC_MII_BUSY_ BIT(0)
#define MAC_MII_ACC_MIIMMD_SHIFT_ (6)
#define MAC_MII_ACC_MIIMMD_MASK_ (0x000007C0)
#define MAC_MII_ACC_MIICL45_ BIT(3)
#define MAC_MII_ACC_MIICMD_MASK_ (0x00000006)
#define MAC_MII_ACC_MIICMD_ADDR_ (0x00000000)
#define MAC_MII_ACC_MIICMD_WRITE_ (0x00000002)
#define MAC_MII_ACC_MIICMD_READ_ (0x00000004)
#define MAC_MII_ACC_MIICMD_READ_INC_ (0x00000006)
#define MAC_MII_DATA (0x124)
#define MAC_EEE_TX_LPI_REQ_DLY_CNT (0x130)
......@@ -214,6 +246,11 @@
#define MAC_WUCSR2 (0x600)
#define SGMII_CTL (0x728)
#define SGMII_CTL_SGMII_ENABLE_ BIT(31)
#define SGMII_CTL_LINK_STATUS_SOURCE_ BIT(8)
#define SGMII_CTL_SGMII_POWER_DN_ BIT(1)
#define INT_STS (0x780)
#define INT_BIT_DMA_RX_(channel) BIT(24 + (channel))
#define INT_BIT_ALL_RX_ (0x0F000000)
......@@ -261,6 +298,8 @@
#define INT_MOD_CFG5 (0x7D4)
#define INT_MOD_CFG6 (0x7D8)
#define INT_MOD_CFG7 (0x7DC)
#define INT_MOD_CFG8 (0x7E0)
#define INT_MOD_CFG9 (0x7E4)
#define PTP_CMD_CTL (0x0A00)
#define PTP_CMD_CTL_PTP_CLK_STP_NSEC_ BIT(6)
......@@ -541,10 +580,12 @@
#define LAN743X_MAX_RX_CHANNELS (4)
#define LAN743X_MAX_TX_CHANNELS (1)
#define PCI11X1X_MAX_TX_CHANNELS (4)
struct lan743x_adapter;
#define LAN743X_USED_RX_CHANNELS (4)
#define LAN743X_USED_TX_CHANNELS (1)
#define PCI11X1X_USED_TX_CHANNELS (4)
#define LAN743X_INT_MOD (400)
#if (LAN743X_USED_RX_CHANNELS > LAN743X_MAX_RX_CHANNELS)
......@@ -553,12 +594,17 @@ struct lan743x_adapter;
#if (LAN743X_USED_TX_CHANNELS > LAN743X_MAX_TX_CHANNELS)
#error Invalid LAN743X_USED_TX_CHANNELS
#endif
#if (PCI11X1X_USED_TX_CHANNELS > PCI11X1X_MAX_TX_CHANNELS)
#error Invalid PCI11X1X_USED_TX_CHANNELS
#endif
/* PCI */
/* SMSC acquired EFAR late 1990's, MCHP acquired SMSC 2012 */
#define PCI_VENDOR_ID_SMSC PCI_VENDOR_ID_EFAR
#define PCI_DEVICE_ID_SMSC_LAN7430 (0x7430)
#define PCI_DEVICE_ID_SMSC_LAN7431 (0x7431)
#define PCI_DEVICE_ID_SMSC_A011 (0xA011)
#define PCI_DEVICE_ID_SMSC_A041 (0xA041)
#define PCI_CONFIG_LENGTH (0x1000)
......@@ -607,13 +653,14 @@ struct lan743x_vector {
};
#define LAN743X_MAX_VECTOR_COUNT (8)
#define PCI11X1X_MAX_VECTOR_COUNT (16)
struct lan743x_intr {
int flags;
unsigned int irq;
struct lan743x_vector vector_list[LAN743X_MAX_VECTOR_COUNT];
struct lan743x_vector vector_list[PCI11X1X_MAX_VECTOR_COUNT];
int number_of_vectors;
bool using_vectors;
......@@ -721,8 +768,13 @@ struct lan743x_adapter {
u8 mac_address[ETH_ALEN];
struct lan743x_phy phy;
struct lan743x_tx tx[LAN743X_MAX_TX_CHANNELS];
struct lan743x_rx rx[LAN743X_MAX_RX_CHANNELS];
struct lan743x_tx tx[PCI11X1X_USED_TX_CHANNELS];
struct lan743x_rx rx[LAN743X_USED_RX_CHANNELS];
bool is_pci11x1x;
bool is_sgmii_en;
u8 max_tx_channels;
u8 used_tx_channels;
u8 max_vector_count;
#define LAN743X_ADAPTER_FLAG_OTP BIT(0)
u32 flags;
......
......@@ -1307,21 +1307,21 @@ int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
switch (config.tx_type) {
case HWTSTAMP_TX_OFF:
for (index = 0; index < LAN743X_MAX_TX_CHANNELS;
index++)
for (index = 0; index < adapter->used_tx_channels;
index++)
lan743x_tx_set_timestamping_mode(&adapter->tx[index],
false, false);
lan743x_ptp_set_sync_ts_insert(adapter, false);
break;
case HWTSTAMP_TX_ON:
for (index = 0; index < LAN743X_MAX_TX_CHANNELS;
for (index = 0; index < adapter->used_tx_channels;
index++)
lan743x_tx_set_timestamping_mode(&adapter->tx[index],
true, false);
lan743x_ptp_set_sync_ts_insert(adapter, false);
break;
case HWTSTAMP_TX_ONESTEP_SYNC:
for (index = 0; index < LAN743X_MAX_TX_CHANNELS;
for (index = 0; index < adapter->used_tx_channels;
index++)
lan743x_tx_set_timestamping_mode(&adapter->tx[index],
true, true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment