Commit c33c9973 authored by Intiyaz Basha's avatar Intiyaz Basha Committed by David S. Miller

liquidio: enhanced ethtool --set-channels feature

Enhancing driver to accept max supported queues for ethtool --set-channels
Signed-off-by: default avatarIntiyaz Basha <intiyaz.basha@cavium.com>
Acked-by: default avatarDerek Chickles <derek.chickles@cavium.com>
Signed-off-by: default avatarFelix Manlunas <felix.manlunas@cavium.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 128ea394
...@@ -1245,7 +1245,7 @@ static void cn23xx_setup_reg_address(struct octeon_device *oct) ...@@ -1245,7 +1245,7 @@ static void cn23xx_setup_reg_address(struct octeon_device *oct)
CN23XX_SLI_MAC_PF_INT_ENB64(oct->pcie_port, oct->pf_num); CN23XX_SLI_MAC_PF_INT_ENB64(oct->pcie_port, oct->pf_num);
} }
static int cn23xx_sriov_config(struct octeon_device *oct) int cn23xx_sriov_config(struct octeon_device *oct)
{ {
struct octeon_cn23xx_pf *cn23xx = (struct octeon_cn23xx_pf *)oct->chip; struct octeon_cn23xx_pf *cn23xx = (struct octeon_cn23xx_pf *)oct->chip;
u32 max_rings, total_rings, max_vfs, rings_per_vf; u32 max_rings, total_rings, max_vfs, rings_per_vf;
...@@ -1269,8 +1269,8 @@ static int cn23xx_sriov_config(struct octeon_device *oct) ...@@ -1269,8 +1269,8 @@ static int cn23xx_sriov_config(struct octeon_device *oct)
break; break;
} }
if (max_rings <= num_present_cpus()) if (oct->sriov_info.num_pf_rings)
num_pf_rings = 1; num_pf_rings = oct->sriov_info.num_pf_rings;
else else
num_pf_rings = num_present_cpus(); num_pf_rings = num_present_cpus();
......
...@@ -61,6 +61,8 @@ u32 cn23xx_pf_get_oq_ticks(struct octeon_device *oct, u32 time_intr_in_us); ...@@ -61,6 +61,8 @@ u32 cn23xx_pf_get_oq_ticks(struct octeon_device *oct, u32 time_intr_in_us);
void cn23xx_dump_pf_initialized_regs(struct octeon_device *oct); void cn23xx_dump_pf_initialized_regs(struct octeon_device *oct);
int cn23xx_sriov_config(struct octeon_device *oct);
int cn23xx_fw_loaded(struct octeon_device *oct); int cn23xx_fw_loaded(struct octeon_device *oct);
void cn23xx_tell_vf_its_macaddr_changed(struct octeon_device *oct, int vfidx, void cn23xx_tell_vf_its_macaddr_changed(struct octeon_device *oct, int vfidx,
......
...@@ -78,7 +78,7 @@ void lio_delete_glists(struct lio *lio) ...@@ -78,7 +78,7 @@ void lio_delete_glists(struct lio *lio)
if (!lio->glist) if (!lio->glist)
return; return;
for (i = 0; i < lio->linfo.num_txpciq; i++) { for (i = 0; i < lio->oct_dev->num_iqs; i++) {
do { do {
g = (struct octnic_gather *) g = (struct octnic_gather *)
lio_list_delete_head(&lio->glist[i]); lio_list_delete_head(&lio->glist[i]);
...@@ -1036,8 +1036,8 @@ int octeon_setup_interrupt(struct octeon_device *oct, u32 num_ioqs) ...@@ -1036,8 +1036,8 @@ int octeon_setup_interrupt(struct octeon_device *oct, u32 num_ioqs)
int num_ioq_vectors; int num_ioq_vectors;
int irqret, err; int irqret, err;
oct->num_msix_irqs = num_ioqs;
if (oct->msix_on) { if (oct->msix_on) {
oct->num_msix_irqs = num_ioqs;
if (OCTEON_CN23XX_PF(oct)) { if (OCTEON_CN23XX_PF(oct)) {
num_interrupts = MAX_IOQ_INTERRUPTS_PER_PF + 1; num_interrupts = MAX_IOQ_INTERRUPTS_PER_PF + 1;
......
...@@ -497,7 +497,7 @@ static void liquidio_deinit_pci(void) ...@@ -497,7 +497,7 @@ static void liquidio_deinit_pci(void)
*/ */
static inline int check_txq_status(struct lio *lio) static inline int check_txq_status(struct lio *lio)
{ {
int numqs = lio->netdev->num_tx_queues; int numqs = lio->netdev->real_num_tx_queues;
int ret_val = 0; int ret_val = 0;
int q, iq; int q, iq;
...@@ -1521,7 +1521,7 @@ static void free_netsgbuf(void *buf) ...@@ -1521,7 +1521,7 @@ static void free_netsgbuf(void *buf)
i++; i++;
} }
iq = skb_iq(lio, skb); iq = skb_iq(lio->oct_dev, skb);
spin_lock(&lio->glist_lock[iq]); spin_lock(&lio->glist_lock[iq]);
list_add_tail(&g->list, &lio->glist[iq]); list_add_tail(&g->list, &lio->glist[iq]);
spin_unlock(&lio->glist_lock[iq]); spin_unlock(&lio->glist_lock[iq]);
...@@ -1564,7 +1564,7 @@ static void free_netsgbuf_with_resp(void *buf) ...@@ -1564,7 +1564,7 @@ static void free_netsgbuf_with_resp(void *buf)
i++; i++;
} }
iq = skb_iq(lio, skb); iq = skb_iq(lio->oct_dev, skb);
spin_lock(&lio->glist_lock[iq]); spin_lock(&lio->glist_lock[iq]);
list_add_tail(&g->list, &lio->glist[iq]); list_add_tail(&g->list, &lio->glist[iq]);
...@@ -1851,11 +1851,6 @@ static int liquidio_open(struct net_device *netdev) ...@@ -1851,11 +1851,6 @@ static int liquidio_open(struct net_device *netdev)
ifstate_set(lio, LIO_IFSTATE_RUNNING); ifstate_set(lio, LIO_IFSTATE_RUNNING);
/* Ready for link status updates */
lio->intf_open = 1;
netif_info(lio, ifup, lio->netdev, "Interface Open, ready for traffic\n");
if (OCTEON_CN23XX_PF(oct)) { if (OCTEON_CN23XX_PF(oct)) {
if (!oct->msix_on) if (!oct->msix_on)
if (setup_tx_poll_fn(netdev)) if (setup_tx_poll_fn(netdev))
...@@ -1865,7 +1860,12 @@ static int liquidio_open(struct net_device *netdev) ...@@ -1865,7 +1860,12 @@ static int liquidio_open(struct net_device *netdev)
return -1; return -1;
} }
start_txqs(netdev); netif_tx_start_all_queues(netdev);
/* Ready for link status updates */
lio->intf_open = 1;
netif_info(lio, ifup, lio->netdev, "Interface Open, ready for traffic\n");
/* tell Octeon to start forwarding packets to host */ /* tell Octeon to start forwarding packets to host */
send_rx_ctrl_cmd(lio, 1); send_rx_ctrl_cmd(lio, 1);
...@@ -1888,11 +1888,15 @@ static int liquidio_stop(struct net_device *netdev) ...@@ -1888,11 +1888,15 @@ static int liquidio_stop(struct net_device *netdev)
ifstate_reset(lio, LIO_IFSTATE_RUNNING); ifstate_reset(lio, LIO_IFSTATE_RUNNING);
netif_tx_disable(netdev); /* Stop any link updates */
lio->intf_open = 0;
stop_txqs(netdev);
/* Inform that netif carrier is down */ /* Inform that netif carrier is down */
netif_carrier_off(netdev); netif_carrier_off(netdev);
lio->intf_open = 0; netif_tx_disable(netdev);
lio->linfo.link.s.link_up = 0; lio->linfo.link.s.link_up = 0;
lio->link_changes++; lio->link_changes++;
...@@ -2332,7 +2336,7 @@ static int liquidio_xmit(struct sk_buff *skb, struct net_device *netdev) ...@@ -2332,7 +2336,7 @@ static int liquidio_xmit(struct sk_buff *skb, struct net_device *netdev)
lio = GET_LIO(netdev); lio = GET_LIO(netdev);
oct = lio->oct_dev; oct = lio->oct_dev;
q_idx = skb_iq(lio, skb); q_idx = skb_iq(oct, skb);
tag = q_idx; tag = q_idx;
iq_no = lio->linfo.txpciq[q_idx].s.q_no; iq_no = lio->linfo.txpciq[q_idx].s.q_no;
...@@ -3298,6 +3302,7 @@ static int setup_nic_devices(struct octeon_device *octeon_dev) ...@@ -3298,6 +3302,7 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)
struct liquidio_if_cfg_resp *resp; struct liquidio_if_cfg_resp *resp;
struct octdev_props *props; struct octdev_props *props;
int retval, num_iqueues, num_oqueues; int retval, num_iqueues, num_oqueues;
int max_num_queues = 0;
union oct_nic_if_cfg if_cfg; union oct_nic_if_cfg if_cfg;
unsigned int base_queue; unsigned int base_queue;
unsigned int gmx_port_id; unsigned int gmx_port_id;
...@@ -3380,7 +3385,7 @@ static int setup_nic_devices(struct octeon_device *octeon_dev) ...@@ -3380,7 +3385,7 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)
sc->callback = lio_if_cfg_callback; sc->callback = lio_if_cfg_callback;
sc->callback_arg = sc; sc->callback_arg = sc;
sc->wait_time = 3000; sc->wait_time = LIO_IFCFG_WAIT_TIME;
retval = octeon_send_soft_command(octeon_dev, sc); retval = octeon_send_soft_command(octeon_dev, sc);
if (retval == IQ_SEND_FAILED) { if (retval == IQ_SEND_FAILED) {
...@@ -3434,11 +3439,20 @@ static int setup_nic_devices(struct octeon_device *octeon_dev) ...@@ -3434,11 +3439,20 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)
resp->cfg_info.oqmask); resp->cfg_info.oqmask);
goto setup_nic_dev_fail; goto setup_nic_dev_fail;
} }
if (OCTEON_CN6XXX(octeon_dev)) {
max_num_queues = CFG_GET_IQ_MAX_Q(CHIP_CONF(octeon_dev,
cn6xxx));
} else if (OCTEON_CN23XX_PF(octeon_dev)) {
max_num_queues = CFG_GET_IQ_MAX_Q(CHIP_CONF(octeon_dev,
cn23xx_pf));
}
dev_dbg(&octeon_dev->pci_dev->dev, dev_dbg(&octeon_dev->pci_dev->dev,
"interface %d, iqmask %016llx, oqmask %016llx, numiqueues %d, numoqueues %d\n", "interface %d, iqmask %016llx, oqmask %016llx, numiqueues %d, numoqueues %d max_num_queues: %d\n",
i, resp->cfg_info.iqmask, resp->cfg_info.oqmask, i, resp->cfg_info.iqmask, resp->cfg_info.oqmask,
num_iqueues, num_oqueues); num_iqueues, num_oqueues, max_num_queues);
netdev = alloc_etherdev_mq(LIO_SIZE, num_iqueues); netdev = alloc_etherdev_mq(LIO_SIZE, max_num_queues);
if (!netdev) { if (!netdev) {
dev_err(&octeon_dev->pci_dev->dev, "Device allocation failed\n"); dev_err(&octeon_dev->pci_dev->dev, "Device allocation failed\n");
...@@ -3453,6 +3467,20 @@ static int setup_nic_devices(struct octeon_device *octeon_dev) ...@@ -3453,6 +3467,20 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)
netdev->netdev_ops = &lionetdevops; netdev->netdev_ops = &lionetdevops;
SWITCHDEV_SET_OPS(netdev, &lio_pf_switchdev_ops); SWITCHDEV_SET_OPS(netdev, &lio_pf_switchdev_ops);
retval = netif_set_real_num_rx_queues(netdev, num_oqueues);
if (retval) {
dev_err(&octeon_dev->pci_dev->dev,
"setting real number rx failed\n");
goto setup_nic_dev_fail;
}
retval = netif_set_real_num_tx_queues(netdev, num_iqueues);
if (retval) {
dev_err(&octeon_dev->pci_dev->dev,
"setting real number tx failed\n");
goto setup_nic_dev_fail;
}
lio = GET_LIO(netdev); lio = GET_LIO(netdev);
memset(lio, 0, sizeof(struct lio)); memset(lio, 0, sizeof(struct lio));
...@@ -4073,7 +4101,9 @@ static int octeon_device_init(struct octeon_device *octeon_dev) ...@@ -4073,7 +4101,9 @@ static int octeon_device_init(struct octeon_device *octeon_dev)
} }
atomic_set(&octeon_dev->status, OCT_DEV_MBOX_SETUP_DONE); atomic_set(&octeon_dev->status, OCT_DEV_MBOX_SETUP_DONE);
if (octeon_allocate_ioq_vector(octeon_dev)) { if (octeon_allocate_ioq_vector
(octeon_dev,
octeon_dev->sriov_info.num_pf_rings)) {
dev_err(&octeon_dev->pci_dev->dev, "OCTEON: ioq vector allocation failed\n"); dev_err(&octeon_dev->pci_dev->dev, "OCTEON: ioq vector allocation failed\n");
return 1; return 1;
} }
......
...@@ -849,7 +849,7 @@ static void free_netsgbuf(void *buf) ...@@ -849,7 +849,7 @@ static void free_netsgbuf(void *buf)
i++; i++;
} }
iq = skb_iq(lio, skb); iq = skb_iq(lio->oct_dev, skb);
spin_lock(&lio->glist_lock[iq]); spin_lock(&lio->glist_lock[iq]);
list_add_tail(&g->list, &lio->glist[iq]); list_add_tail(&g->list, &lio->glist[iq]);
...@@ -893,7 +893,7 @@ static void free_netsgbuf_with_resp(void *buf) ...@@ -893,7 +893,7 @@ static void free_netsgbuf_with_resp(void *buf)
i++; i++;
} }
iq = skb_iq(lio, skb); iq = skb_iq(lio->oct_dev, skb);
spin_lock(&lio->glist_lock[iq]); spin_lock(&lio->glist_lock[iq]);
list_add_tail(&g->list, &lio->glist[iq]); list_add_tail(&g->list, &lio->glist[iq]);
...@@ -1407,7 +1407,7 @@ static int liquidio_xmit(struct sk_buff *skb, struct net_device *netdev) ...@@ -1407,7 +1407,7 @@ static int liquidio_xmit(struct sk_buff *skb, struct net_device *netdev)
lio = GET_LIO(netdev); lio = GET_LIO(netdev);
oct = lio->oct_dev; oct = lio->oct_dev;
q_idx = skb_iq(lio, skb); q_idx = skb_iq(lio->oct_dev, skb);
tag = q_idx; tag = q_idx;
iq_no = lio->linfo.txpciq[q_idx].s.q_no; iq_no = lio->linfo.txpciq[q_idx].s.q_no;
...@@ -2339,7 +2339,7 @@ static int octeon_device_init(struct octeon_device *oct) ...@@ -2339,7 +2339,7 @@ static int octeon_device_init(struct octeon_device *oct)
} }
atomic_set(&oct->status, OCT_DEV_MBOX_SETUP_DONE); atomic_set(&oct->status, OCT_DEV_MBOX_SETUP_DONE);
if (octeon_allocate_ioq_vector(oct)) { if (octeon_allocate_ioq_vector(oct, oct->sriov_info.rings_per_vf)) {
dev_err(&oct->pci_dev->dev, "ioq vector allocation failed\n"); dev_err(&oct->pci_dev->dev, "ioq vector allocation failed\n");
return 1; return 1;
} }
......
...@@ -84,6 +84,7 @@ enum octeon_tag_type { ...@@ -84,6 +84,7 @@ enum octeon_tag_type {
#define OPCODE_NIC_IF_CFG 0x09 #define OPCODE_NIC_IF_CFG 0x09
#define OPCODE_NIC_VF_DRV_NOTICE 0x0A #define OPCODE_NIC_VF_DRV_NOTICE 0x0A
#define OPCODE_NIC_INTRMOD_PARAMS 0x0B #define OPCODE_NIC_INTRMOD_PARAMS 0x0B
#define OPCODE_NIC_QCOUNT_UPDATE 0x12
#define OPCODE_NIC_SET_TRUSTED_VF 0x13 #define OPCODE_NIC_SET_TRUSTED_VF 0x13
#define OPCODE_NIC_SYNC_OCTEON_TIME 0x14 #define OPCODE_NIC_SYNC_OCTEON_TIME 0x14
#define VF_DRV_LOADED 1 #define VF_DRV_LOADED 1
......
...@@ -824,23 +824,18 @@ int octeon_deregister_device(struct octeon_device *oct) ...@@ -824,23 +824,18 @@ int octeon_deregister_device(struct octeon_device *oct)
} }
int int
octeon_allocate_ioq_vector(struct octeon_device *oct) octeon_allocate_ioq_vector(struct octeon_device *oct, u32 num_ioqs)
{ {
int i, num_ioqs = 0;
struct octeon_ioq_vector *ioq_vector; struct octeon_ioq_vector *ioq_vector;
int cpu_num; int cpu_num;
int size; int size;
int i;
if (OCTEON_CN23XX_PF(oct))
num_ioqs = oct->sriov_info.num_pf_rings;
else if (OCTEON_CN23XX_VF(oct))
num_ioqs = oct->sriov_info.rings_per_vf;
size = sizeof(struct octeon_ioq_vector) * num_ioqs; size = sizeof(struct octeon_ioq_vector) * num_ioqs;
oct->ioq_vector = vzalloc(size); oct->ioq_vector = vzalloc(size);
if (!oct->ioq_vector) if (!oct->ioq_vector)
return 1; return -1;
for (i = 0; i < num_ioqs; i++) { for (i = 0; i < num_ioqs; i++) {
ioq_vector = &oct->ioq_vector[i]; ioq_vector = &oct->ioq_vector[i];
ioq_vector->oct_dev = oct; ioq_vector->oct_dev = oct;
...@@ -856,6 +851,7 @@ octeon_allocate_ioq_vector(struct octeon_device *oct) ...@@ -856,6 +851,7 @@ octeon_allocate_ioq_vector(struct octeon_device *oct)
else else
ioq_vector->ioq_num = i; ioq_vector->ioq_num = i;
} }
return 0; return 0;
} }
......
...@@ -867,7 +867,7 @@ void *oct_get_config_info(struct octeon_device *oct, u16 card_type); ...@@ -867,7 +867,7 @@ void *oct_get_config_info(struct octeon_device *oct, u16 card_type);
struct octeon_config *octeon_get_conf(struct octeon_device *oct); struct octeon_config *octeon_get_conf(struct octeon_device *oct);
void octeon_free_ioq_vector(struct octeon_device *oct); void octeon_free_ioq_vector(struct octeon_device *oct);
int octeon_allocate_ioq_vector(struct octeon_device *oct); int octeon_allocate_ioq_vector(struct octeon_device *oct, u32 num_ioqs);
void lio_enable_irq(struct octeon_droq *droq, struct octeon_instr_queue *iq); void lio_enable_irq(struct octeon_droq *droq, struct octeon_instr_queue *iq);
/* LiquidIO driver pivate flags */ /* LiquidIO driver pivate flags */
......
...@@ -47,6 +47,8 @@ struct liquidio_if_cfg_resp { ...@@ -47,6 +47,8 @@ struct liquidio_if_cfg_resp {
u64 status; u64 status;
}; };
#define LIO_IFCFG_WAIT_TIME 3000 /* In milli seconds */
/* Structure of a node in list of gather components maintained by /* Structure of a node in list of gather components maintained by
* NIC driver for each network device. * NIC driver for each network device.
*/ */
...@@ -546,7 +548,7 @@ static inline void stop_txqs(struct net_device *netdev) ...@@ -546,7 +548,7 @@ static inline void stop_txqs(struct net_device *netdev)
{ {
int i; int i;
for (i = 0; i < netdev->num_tx_queues; i++) for (i = 0; i < netdev->real_num_tx_queues; i++)
netif_stop_subqueue(netdev, i); netif_stop_subqueue(netdev, i);
} }
...@@ -559,7 +561,7 @@ static inline void wake_txqs(struct net_device *netdev) ...@@ -559,7 +561,7 @@ static inline void wake_txqs(struct net_device *netdev)
struct lio *lio = GET_LIO(netdev); struct lio *lio = GET_LIO(netdev);
int i, qno; int i, qno;
for (i = 0; i < netdev->num_tx_queues; i++) { for (i = 0; i < netdev->real_num_tx_queues; i++) {
qno = lio->linfo.txpciq[i % lio->oct_dev->num_iqs].s.q_no; qno = lio->linfo.txpciq[i % lio->oct_dev->num_iqs].s.q_no;
if (__netif_subqueue_stopped(netdev, i)) { if (__netif_subqueue_stopped(netdev, i)) {
...@@ -580,14 +582,14 @@ static inline void start_txqs(struct net_device *netdev) ...@@ -580,14 +582,14 @@ static inline void start_txqs(struct net_device *netdev)
int i; int i;
if (lio->linfo.link.s.link_up) { if (lio->linfo.link.s.link_up) {
for (i = 0; i < netdev->num_tx_queues; i++) for (i = 0; i < netdev->real_num_tx_queues; i++)
netif_start_subqueue(netdev, i); netif_start_subqueue(netdev, i);
} }
} }
static inline int skb_iq(struct lio *lio, struct sk_buff *skb) static inline int skb_iq(struct octeon_device *oct, struct sk_buff *skb)
{ {
return skb->queue_mapping % lio->linfo.num_txpciq; return skb->queue_mapping % oct->num_iqs;
} }
/** /**
......
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