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

Merge branch 'liquidio-CN23XX-VF-support'

Raghu Vatsavayi says:

====================
liquidio CN23XX VF support

Following is the V6 patch series for adding VF support on
CN23XX devices. This version addressed:
1) Your concern for ordering of local variable declarations
   from longest to shortest line.
2) Removed module parameters max_vfs, num_queues_per_{p,v}f.
3) Minor changes for fixing new checkpatch script related
   errors on pre-existing driver.
4) Fixed compilation issues when CONFIG_PCI_IOV/CONFIG_PCI_ATS
   options are disabled.
5) Modified qualifiers for printing mac addresses with pM format.

I will post remaining VF patches soon after this patchseries is
applied. Please apply patches in the following order as some of
the patches depend on earlier patches.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 3418c681 97a25326
...@@ -11,6 +11,7 @@ liquidio-$(CONFIG_LIQUIDIO) += lio_ethtool.o \ ...@@ -11,6 +11,7 @@ liquidio-$(CONFIG_LIQUIDIO) += lio_ethtool.o \
cn66xx_device.o \ cn66xx_device.o \
cn68xx_device.o \ cn68xx_device.o \
cn23xx_pf_device.o \ cn23xx_pf_device.o \
octeon_mailbox.o \
octeon_mem_ops.o \ octeon_mem_ops.o \
octeon_droq.o \ octeon_droq.o \
octeon_nic.o octeon_nic.o
......
/********************************************************************** /**********************************************************************
* Author: Cavium, Inc. * Author: Cavium, Inc.
* *
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more details.
* details. ***********************************************************************/
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/
/*! \file cn23xx_device.h /*! \file cn23xx_device.h
* \brief Host Driver: Routines that perform CN23XX specific operations. * \brief Host Driver: Routines that perform CN23XX specific operations.
*/ */
#ifndef __CN23XX_PF_DEVICE_H__ #ifndef __CN23XX_PF_DEVICE_H__
#define __CN23XX_PF_DEVICE_H__ #define __CN23XX_PF_DEVICE_H__
#include "cn23xx_pf_regs.h" #include "cn23xx_pf_regs.h"
#define LIO_CMD_WAIT_TM 100
/* Register address and configuration for a CN23XX devices. /* Register address and configuration for a CN23XX devices.
* If device specific changes need to be made then add a struct to include * If device specific changes need to be made then add a struct to include
* device specific fields as shown in the commented section * device specific fields as shown in the commented section
...@@ -56,4 +53,7 @@ u32 cn23xx_pf_get_oq_ticks(struct octeon_device *oct, u32 time_intr_in_us); ...@@ -56,4 +53,7 @@ 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_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,
u8 *mac);
#endif #endif
/********************************************************************** /**********************************************************************
* Author: Cavium, Inc. * Author: Cavium, Inc.
* *
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more details.
* details. ***********************************************************************/
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/
/*! \file cn23xx_regs.h /*! \file cn23xx_regs.h
* \brief Host Driver: Register Address and Register Mask values for * \brief Host Driver: Register Address and Register Mask values for
* Octeon CN23XX devices. * Octeon CN23XX devices.
*/ */
#ifndef __CN23XX_PF_REGS_H__ #ifndef __CN23XX_PF_REGS_H__
#define __CN23XX_PF_REGS_H__ #define __CN23XX_PF_REGS_H__
...@@ -63,7 +58,7 @@ ...@@ -63,7 +58,7 @@
#define CN23XX_CONFIG_SRIOV_BAR_START 0x19C #define CN23XX_CONFIG_SRIOV_BAR_START 0x19C
#define CN23XX_CONFIG_SRIOV_BARX(i) \ #define CN23XX_CONFIG_SRIOV_BARX(i) \
(CN23XX_CONFIG_SRIOV_BAR_START + (i * 4)) (CN23XX_CONFIG_SRIOV_BAR_START + ((i) * 4))
#define CN23XX_CONFIG_SRIOV_BAR_PF 0x08 #define CN23XX_CONFIG_SRIOV_BAR_PF 0x08
#define CN23XX_CONFIG_SRIOV_BAR_64BIT 0x04 #define CN23XX_CONFIG_SRIOV_BAR_64BIT 0x04
#define CN23XX_CONFIG_SRIOV_BAR_IO 0x01 #define CN23XX_CONFIG_SRIOV_BAR_IO 0x01
...@@ -513,7 +508,7 @@ ...@@ -513,7 +508,7 @@
/* 4 Registers (64 - bit) */ /* 4 Registers (64 - bit) */
#define CN23XX_SLI_S2M_PORT_CTL_START 0x23D80 #define CN23XX_SLI_S2M_PORT_CTL_START 0x23D80
#define CN23XX_SLI_S2M_PORTX_CTL(port) \ #define CN23XX_SLI_S2M_PORTX_CTL(port) \
(CN23XX_SLI_S2M_PORT_CTL_START + (port * 0x10)) (CN23XX_SLI_S2M_PORT_CTL_START + ((port) * 0x10))
#define CN23XX_SLI_MAC_NUMBER 0x20050 #define CN23XX_SLI_MAC_NUMBER 0x20050
...@@ -554,26 +549,26 @@ ...@@ -554,26 +549,26 @@
* Provides DMA Engine Queue Enable * Provides DMA Engine Queue Enable
*/ */
#define CN23XX_DPI_DMA_ENG0_ENB 0x0001df0000000080ULL #define CN23XX_DPI_DMA_ENG0_ENB 0x0001df0000000080ULL
#define CN23XX_DPI_DMA_ENG_ENB(eng) (CN23XX_DPI_DMA_ENG0_ENB + (eng * 8)) #define CN23XX_DPI_DMA_ENG_ENB(eng) (CN23XX_DPI_DMA_ENG0_ENB + ((eng) * 8))
/* 8 register (64-bit) - DPI_DMA(0..7)_REQQ_CTL /* 8 register (64-bit) - DPI_DMA(0..7)_REQQ_CTL
* Provides control bits for transaction on 8 Queues * Provides control bits for transaction on 8 Queues
*/ */
#define CN23XX_DPI_DMA_REQQ0_CTL 0x0001df0000000180ULL #define CN23XX_DPI_DMA_REQQ0_CTL 0x0001df0000000180ULL
#define CN23XX_DPI_DMA_REQQ_CTL(q_no) \ #define CN23XX_DPI_DMA_REQQ_CTL(q_no) \
(CN23XX_DPI_DMA_REQQ0_CTL + (q_no * 8)) (CN23XX_DPI_DMA_REQQ0_CTL + ((q_no) * 8))
/* 6 register (64-bit) - DPI_ENG(0..5)_BUF /* 6 register (64-bit) - DPI_ENG(0..5)_BUF
* Provides DMA Engine FIFO (Queue) Size * Provides DMA Engine FIFO (Queue) Size
*/ */
#define CN23XX_DPI_DMA_ENG0_BUF 0x0001df0000000880ULL #define CN23XX_DPI_DMA_ENG0_BUF 0x0001df0000000880ULL
#define CN23XX_DPI_DMA_ENG_BUF(eng) \ #define CN23XX_DPI_DMA_ENG_BUF(eng) \
(CN23XX_DPI_DMA_ENG0_BUF + (eng * 8)) (CN23XX_DPI_DMA_ENG0_BUF + ((eng) * 8))
/* 4 Registers (64-bit) */ /* 4 Registers (64-bit) */
#define CN23XX_DPI_SLI_PRT_CFG_START 0x0001df0000000900ULL #define CN23XX_DPI_SLI_PRT_CFG_START 0x0001df0000000900ULL
#define CN23XX_DPI_SLI_PRTX_CFG(port) \ #define CN23XX_DPI_SLI_PRTX_CFG(port) \
(CN23XX_DPI_SLI_PRT_CFG_START + (port * 0x8)) (CN23XX_DPI_SLI_PRT_CFG_START + ((port) * 0x8))
/* Masks for DPI_DMA_CONTROL Register */ /* Masks for DPI_DMA_CONTROL Register */
#define CN23XX_DPI_DMA_COMMIT_MODE BIT_ULL(58) #define CN23XX_DPI_DMA_COMMIT_MODE BIT_ULL(58)
......
/********************************************************************** /**********************************************************************
* Author: Cavium, Inc. * Author: Cavium, Inc.
* *
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more details.
* details. ***********************************************************************/
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include "liquidio_common.h" #include "liquidio_common.h"
...@@ -275,7 +271,6 @@ void lio_cn6xxx_setup_iq_regs(struct octeon_device *oct, u32 iq_no) ...@@ -275,7 +271,6 @@ void lio_cn6xxx_setup_iq_regs(struct octeon_device *oct, u32 iq_no)
{ {
struct octeon_instr_queue *iq = oct->instr_queue[iq_no]; struct octeon_instr_queue *iq = oct->instr_queue[iq_no];
/* Disable Packet-by-Packet mode; No Parse Mode or Skip length */
octeon_write_csr64(oct, CN6XXX_SLI_IQ_PKT_INSTR_HDR64(iq_no), 0); octeon_write_csr64(oct, CN6XXX_SLI_IQ_PKT_INSTR_HDR64(iq_no), 0);
/* Write the start of the input queue's ring and its size */ /* Write the start of the input queue's ring and its size */
...@@ -378,7 +373,7 @@ void lio_cn6xxx_disable_io_queues(struct octeon_device *oct) ...@@ -378,7 +373,7 @@ void lio_cn6xxx_disable_io_queues(struct octeon_device *oct)
/* Reset the doorbell register for each Input queue. */ /* Reset the doorbell register for each Input queue. */
for (i = 0; i < MAX_OCTEON_INSTR_QUEUES(oct); i++) { for (i = 0; i < MAX_OCTEON_INSTR_QUEUES(oct); i++) {
if (!(oct->io_qmask.iq & (1ULL << i))) if (!(oct->io_qmask.iq & BIT_ULL(i)))
continue; continue;
octeon_write_csr(oct, CN6XXX_SLI_IQ_DOORBELL(i), 0xFFFFFFFF); octeon_write_csr(oct, CN6XXX_SLI_IQ_DOORBELL(i), 0xFFFFFFFF);
d32 = octeon_read_csr(oct, CN6XXX_SLI_IQ_DOORBELL(i)); d32 = octeon_read_csr(oct, CN6XXX_SLI_IQ_DOORBELL(i));
...@@ -400,9 +395,8 @@ void lio_cn6xxx_disable_io_queues(struct octeon_device *oct) ...@@ -400,9 +395,8 @@ void lio_cn6xxx_disable_io_queues(struct octeon_device *oct)
; ;
/* Reset the doorbell register for each Output queue. */ /* Reset the doorbell register for each Output queue. */
/* for (i = 0; i < oct->num_oqs; i++) { */
for (i = 0; i < MAX_OCTEON_OUTPUT_QUEUES(oct); i++) { for (i = 0; i < MAX_OCTEON_OUTPUT_QUEUES(oct); i++) {
if (!(oct->io_qmask.oq & (1ULL << i))) if (!(oct->io_qmask.oq & BIT_ULL(i)))
continue; continue;
octeon_write_csr(oct, CN6XXX_SLI_OQ_PKTS_CREDIT(i), 0xFFFFFFFF); octeon_write_csr(oct, CN6XXX_SLI_OQ_PKTS_CREDIT(i), 0xFFFFFFFF);
d32 = octeon_read_csr(oct, CN6XXX_SLI_OQ_PKTS_CREDIT(i)); d32 = octeon_read_csr(oct, CN6XXX_SLI_OQ_PKTS_CREDIT(i));
...@@ -537,15 +531,14 @@ static int lio_cn6xxx_process_droq_intr_regs(struct octeon_device *oct) ...@@ -537,15 +531,14 @@ static int lio_cn6xxx_process_droq_intr_regs(struct octeon_device *oct)
oct->droq_intr = 0; oct->droq_intr = 0;
/* for (oq_no = 0; oq_no < oct->num_oqs; oq_no++) { */
for (oq_no = 0; oq_no < MAX_OCTEON_OUTPUT_QUEUES(oct); oq_no++) { for (oq_no = 0; oq_no < MAX_OCTEON_OUTPUT_QUEUES(oct); oq_no++) {
if (!(droq_mask & (1ULL << oq_no))) if (!(droq_mask & BIT_ULL(oq_no)))
continue; continue;
droq = oct->droq[oq_no]; droq = oct->droq[oq_no];
pkt_count = octeon_droq_check_hw_for_pkts(droq); pkt_count = octeon_droq_check_hw_for_pkts(droq);
if (pkt_count) { if (pkt_count) {
oct->droq_intr |= (1ULL << oq_no); oct->droq_intr |= BIT_ULL(oq_no);
if (droq->ops.poll_mode) { if (droq->ops.poll_mode) {
u32 value; u32 value;
u32 reg; u32 reg;
...@@ -721,8 +714,6 @@ int lio_setup_cn66xx_octeon_device(struct octeon_device *oct) ...@@ -721,8 +714,6 @@ int lio_setup_cn66xx_octeon_device(struct octeon_device *oct)
int lio_validate_cn6xxx_config_info(struct octeon_device *oct, int lio_validate_cn6xxx_config_info(struct octeon_device *oct,
struct octeon_config *conf6xxx) struct octeon_config *conf6xxx)
{ {
/* int total_instrs = 0; */
if (CFG_GET_IQ_MAX_Q(conf6xxx) > CN6XXX_MAX_INPUT_QUEUES) { if (CFG_GET_IQ_MAX_Q(conf6xxx) > CN6XXX_MAX_INPUT_QUEUES) {
dev_err(&oct->pci_dev->dev, "%s: Num IQ (%d) exceeds Max (%d)\n", dev_err(&oct->pci_dev->dev, "%s: Num IQ (%d) exceeds Max (%d)\n",
__func__, CFG_GET_IQ_MAX_Q(conf6xxx), __func__, CFG_GET_IQ_MAX_Q(conf6xxx),
......
/********************************************************************** /**********************************************************************
* Author: Cavium, Inc. * Author: Cavium, Inc.
* *
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more details.
* details. ***********************************************************************/
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/
/*! \file cn66xx_device.h /*! \file cn66xx_device.h
* \brief Host Driver: Routines that perform CN66XX specific operations. * \brief Host Driver: Routines that perform CN66XX specific operations.
*/ */
...@@ -96,8 +91,8 @@ void lio_cn6xxx_setup_reg_address(struct octeon_device *oct, void *chip, ...@@ -96,8 +91,8 @@ void lio_cn6xxx_setup_reg_address(struct octeon_device *oct, void *chip,
struct octeon_reg_list *reg_list); struct octeon_reg_list *reg_list);
u32 lio_cn6xxx_coprocessor_clock(struct octeon_device *oct); u32 lio_cn6xxx_coprocessor_clock(struct octeon_device *oct);
u32 lio_cn6xxx_get_oq_ticks(struct octeon_device *oct, u32 time_intr_in_us); u32 lio_cn6xxx_get_oq_ticks(struct octeon_device *oct, u32 time_intr_in_us);
int lio_setup_cn66xx_octeon_device(struct octeon_device *); int lio_setup_cn66xx_octeon_device(struct octeon_device *oct);
int lio_validate_cn6xxx_config_info(struct octeon_device *oct, int lio_validate_cn6xxx_config_info(struct octeon_device *oct,
struct octeon_config *); struct octeon_config *conf6xxx);
#endif #endif
/********************************************************************** /**********************************************************************
* Author: Cavium, Inc. * Author: Cavium, Inc.
* *
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more details.
* details. ***********************************************************************/
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/
/*! \file cn66xx_regs.h /*! \file cn66xx_regs.h
* \brief Host Driver: Register Address and Register Mask values for * \brief Host Driver: Register Address and Register Mask values for
* Octeon CN66XX devices. * Octeon CN66XX devices.
...@@ -443,10 +438,10 @@ ...@@ -443,10 +438,10 @@
#define CN6XXX_SLI_S2M_PORT0_CTL 0x3D80 #define CN6XXX_SLI_S2M_PORT0_CTL 0x3D80
#define CN6XXX_SLI_S2M_PORT1_CTL 0x3D90 #define CN6XXX_SLI_S2M_PORT1_CTL 0x3D90
#define CN6XXX_SLI_S2M_PORTX_CTL(port) \ #define CN6XXX_SLI_S2M_PORTX_CTL(port) \
(CN6XXX_SLI_S2M_PORT0_CTL + (port * 0x10)) (CN6XXX_SLI_S2M_PORT0_CTL + ((port) * 0x10))
#define CN6XXX_SLI_INT_ENB64(port) \ #define CN6XXX_SLI_INT_ENB64(port) \
(CN6XXX_SLI_INT_ENB64_PORT0 + (port * 0x10)) (CN6XXX_SLI_INT_ENB64_PORT0 + ((port) * 0x10))
#define CN6XXX_SLI_MAC_NUMBER 0x3E00 #define CN6XXX_SLI_MAC_NUMBER 0x3E00
...@@ -458,7 +453,7 @@ ...@@ -458,7 +453,7 @@
#define CN6XXX_PCI_BAR1_OFFSET 0x8 #define CN6XXX_PCI_BAR1_OFFSET 0x8
#define CN6XXX_BAR1_REG(idx, port) \ #define CN6XXX_BAR1_REG(idx, port) \
(CN6XXX_BAR1_INDEX_START + (port * CN6XXX_PEM_OFFSET) + \ (CN6XXX_BAR1_INDEX_START + ((port) * CN6XXX_PEM_OFFSET) + \
(CN6XXX_PCI_BAR1_OFFSET * (idx))) (CN6XXX_PCI_BAR1_OFFSET * (idx)))
/*############################ DPI #########################*/ /*############################ DPI #########################*/
...@@ -476,17 +471,17 @@ ...@@ -476,17 +471,17 @@
#define CN6XXX_DPI_DMA_ENG0_ENB 0x0001df0000000080ULL #define CN6XXX_DPI_DMA_ENG0_ENB 0x0001df0000000080ULL
#define CN6XXX_DPI_DMA_ENG_ENB(q_no) \ #define CN6XXX_DPI_DMA_ENG_ENB(q_no) \
(CN6XXX_DPI_DMA_ENG0_ENB + (q_no * 8)) (CN6XXX_DPI_DMA_ENG0_ENB + ((q_no) * 8))
#define CN6XXX_DPI_DMA_ENG0_BUF 0x0001df0000000880ULL #define CN6XXX_DPI_DMA_ENG0_BUF 0x0001df0000000880ULL
#define CN6XXX_DPI_DMA_ENG_BUF(q_no) \ #define CN6XXX_DPI_DMA_ENG_BUF(q_no) \
(CN6XXX_DPI_DMA_ENG0_BUF + (q_no * 8)) (CN6XXX_DPI_DMA_ENG0_BUF + ((q_no) * 8))
#define CN6XXX_DPI_SLI_PRT0_CFG 0x0001df0000000900ULL #define CN6XXX_DPI_SLI_PRT0_CFG 0x0001df0000000900ULL
#define CN6XXX_DPI_SLI_PRT1_CFG 0x0001df0000000908ULL #define CN6XXX_DPI_SLI_PRT1_CFG 0x0001df0000000908ULL
#define CN6XXX_DPI_SLI_PRTX_CFG(port) \ #define CN6XXX_DPI_SLI_PRTX_CFG(port) \
(CN6XXX_DPI_SLI_PRT0_CFG + (port * 0x10)) (CN6XXX_DPI_SLI_PRT0_CFG + ((port) * 0x10))
#define CN6XXX_DPI_DMA_COMMIT_MODE BIT_ULL(58) #define CN6XXX_DPI_DMA_COMMIT_MODE BIT_ULL(58)
#define CN6XXX_DPI_DMA_PKT_HP BIT_ULL(57) #define CN6XXX_DPI_DMA_PKT_HP BIT_ULL(57)
......
/********************************************************************** /**********************************************************************
* Author: Cavium, Inc. * Author: Cavium, Inc.
* *
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more details.
* details. ***********************************************************************/
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include "liquidio_common.h" #include "liquidio_common.h"
...@@ -76,7 +72,7 @@ static void lio_cn68xx_setup_pkt_ctl_regs(struct octeon_device *oct) ...@@ -76,7 +72,7 @@ static void lio_cn68xx_setup_pkt_ctl_regs(struct octeon_device *oct)
pktctl = octeon_read_csr64(oct, CN6XXX_SLI_PKT_CTL); pktctl = octeon_read_csr64(oct, CN6XXX_SLI_PKT_CTL);
/* 68XX specific */ /* 68XX specific */
max_oqs = CFG_GET_OQ_MAX_Q(CHIP_FIELD(oct, cn6xxx, conf)); max_oqs = CFG_GET_OQ_MAX_Q(CHIP_CONF(oct, cn6xxx));
tx_pipe = octeon_read_csr64(oct, CN68XX_SLI_TX_PIPE); tx_pipe = octeon_read_csr64(oct, CN68XX_SLI_TX_PIPE);
tx_pipe &= 0xffffffffff00ffffULL; /* clear out NUMP field */ tx_pipe &= 0xffffffffff00ffffULL; /* clear out NUMP field */
tx_pipe |= max_oqs << 16; /* put max_oqs in NUMP field */ tx_pipe |= max_oqs << 16; /* put max_oqs in NUMP field */
......
/********************************************************************** /**********************************************************************
* Author: Cavium, Inc. * Author: Cavium, Inc.
* *
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more details.
* details. ***********************************************************************/
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/
/*! \file cn68xx_device.h /*! \file cn68xx_device.h
* \brief Host Driver: Routines that perform CN68XX specific operations. * \brief Host Driver: Routines that perform CN68XX specific operations.
*/ */
......
/********************************************************************** /**********************************************************************
* Author: Cavium, Inc. * Author: Cavium, Inc.
* *
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more details.
* details. ***********************************************************************/
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/
/*! \file cn68xx_regs.h /*! \file cn68xx_regs.h
* \brief Host Driver: Register Address and Register Mask values for * \brief Host Driver: Register Address and Register Mask values for
* Octeon CN68XX devices. The register map for CN66XX is the same * Octeon CN68XX devices. The register map for CN66XX is the same
......
/********************************************************************** /**********************************************************************
* Author: Cavium, Inc. * Author: Cavium, Inc.
* *
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more details.
* details. ***********************************************************************/
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/if_vlan.h> #include <linux/if_vlan.h>
#include "liquidio_common.h" #include "liquidio_common.h"
...@@ -264,3 +260,34 @@ void liquidio_link_ctrl_cmd_completion(void *nctrl_ptr) ...@@ -264,3 +260,34 @@ void liquidio_link_ctrl_cmd_completion(void *nctrl_ptr)
nctrl->ncmd.s.cmd); nctrl->ncmd.s.cmd);
} }
} }
void octeon_pf_changed_vf_macaddr(struct octeon_device *oct, u8 *mac)
{
bool macaddr_changed = false;
struct net_device *netdev;
struct lio *lio;
rtnl_lock();
netdev = oct->props[0].netdev;
lio = GET_LIO(netdev);
lio->linfo.macaddr_is_admin_asgnd = true;
if (!ether_addr_equal(netdev->dev_addr, mac)) {
macaddr_changed = true;
ether_addr_copy(netdev->dev_addr, mac);
ether_addr_copy(((u8 *)&lio->linfo.hw_addr) + 2, mac);
call_netdevice_notifiers(NETDEV_CHANGEADDR, netdev);
}
rtnl_unlock();
if (macaddr_changed)
dev_info(&oct->pci_dev->dev,
"PF changed VF's MAC address to %pM\n", mac);
/* no need to notify the firmware of the macaddr change because
* the PF did that already
*/
}
/********************************************************************** /**********************************************************************
* Author: Cavium, Inc. * Author: Cavium, Inc.
* *
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more details.
* details. ***********************************************************************/
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/net_tstamp.h> #include <linux/net_tstamp.h>
#include <linux/pci.h> #include <linux/pci.h>
...@@ -74,7 +70,6 @@ enum { ...@@ -74,7 +70,6 @@ enum {
INTERFACE_MODE_MIXED, INTERFACE_MODE_MIXED,
}; };
#define ARRAY_LENGTH(a) (sizeof(a) / sizeof((a)[0]))
#define OCT_ETHTOOL_REGDUMP_LEN 4096 #define OCT_ETHTOOL_REGDUMP_LEN 4096
#define OCT_ETHTOOL_REGDUMP_LEN_23XX (4096 * 11) #define OCT_ETHTOOL_REGDUMP_LEN_23XX (4096 * 11)
#define OCT_ETHTOOL_REGSVER 1 #define OCT_ETHTOOL_REGSVER 1
...@@ -87,8 +82,8 @@ static const char oct_stats_strings[][ETH_GSTRING_LEN] = { ...@@ -87,8 +82,8 @@ static const char oct_stats_strings[][ETH_GSTRING_LEN] = {
"tx_bytes", "tx_bytes",
"rx_errors", /*jabber_err+l2_err+frame_err */ "rx_errors", /*jabber_err+l2_err+frame_err */
"tx_errors", /*fw_err_pko+fw_err_link+fw_err_drop */ "tx_errors", /*fw_err_pko+fw_err_link+fw_err_drop */
"rx_dropped", /*st->fromwire.total_rcvd - st->fromwire.fw_total_rcvd "rx_dropped", /*st->fromwire.total_rcvd - st->fromwire.fw_total_rcvd +
*+st->fromwire.dmac_drop + st->fromwire.fw_err_drop *st->fromwire.dmac_drop + st->fromwire.fw_err_drop
*/ */
"tx_dropped", "tx_dropped",
...@@ -259,14 +254,14 @@ lio_ethtool_get_channels(struct net_device *dev, ...@@ -259,14 +254,14 @@ lio_ethtool_get_channels(struct net_device *dev,
u32 max_rx = 0, max_tx = 0, tx_count = 0, rx_count = 0; u32 max_rx = 0, max_tx = 0, tx_count = 0, rx_count = 0;
if (OCTEON_CN6XXX(oct)) { if (OCTEON_CN6XXX(oct)) {
struct octeon_config *conf6x = CHIP_FIELD(oct, cn6xxx, conf); struct octeon_config *conf6x = CHIP_CONF(oct, cn6xxx);
max_rx = CFG_GET_OQ_MAX_Q(conf6x); max_rx = CFG_GET_OQ_MAX_Q(conf6x);
max_tx = CFG_GET_IQ_MAX_Q(conf6x); max_tx = CFG_GET_IQ_MAX_Q(conf6x);
rx_count = CFG_GET_NUM_RXQS_NIC_IF(conf6x, lio->ifidx); rx_count = CFG_GET_NUM_RXQS_NIC_IF(conf6x, lio->ifidx);
tx_count = CFG_GET_NUM_TXQS_NIC_IF(conf6x, lio->ifidx); tx_count = CFG_GET_NUM_TXQS_NIC_IF(conf6x, lio->ifidx);
} else if (OCTEON_CN23XX_PF(oct)) { } else if (OCTEON_CN23XX_PF(oct)) {
struct octeon_config *conf23 = CHIP_FIELD(oct, cn23xx_pf, conf); struct octeon_config *conf23 = CHIP_CONF(oct, cn23xx_pf);
max_rx = CFG_GET_OQ_MAX_Q(conf23); max_rx = CFG_GET_OQ_MAX_Q(conf23);
max_tx = CFG_GET_IQ_MAX_Q(conf23); max_tx = CFG_GET_IQ_MAX_Q(conf23);
...@@ -589,14 +584,14 @@ lio_ethtool_get_ringparam(struct net_device *netdev, ...@@ -589,14 +584,14 @@ lio_ethtool_get_ringparam(struct net_device *netdev,
rx_pending = 0; rx_pending = 0;
if (OCTEON_CN6XXX(oct)) { if (OCTEON_CN6XXX(oct)) {
struct octeon_config *conf6x = CHIP_FIELD(oct, cn6xxx, conf); struct octeon_config *conf6x = CHIP_CONF(oct, cn6xxx);
tx_max_pending = CN6XXX_MAX_IQ_DESCRIPTORS; tx_max_pending = CN6XXX_MAX_IQ_DESCRIPTORS;
rx_max_pending = CN6XXX_MAX_OQ_DESCRIPTORS; rx_max_pending = CN6XXX_MAX_OQ_DESCRIPTORS;
rx_pending = CFG_GET_NUM_RX_DESCS_NIC_IF(conf6x, lio->ifidx); rx_pending = CFG_GET_NUM_RX_DESCS_NIC_IF(conf6x, lio->ifidx);
tx_pending = CFG_GET_NUM_TX_DESCS_NIC_IF(conf6x, lio->ifidx); tx_pending = CFG_GET_NUM_TX_DESCS_NIC_IF(conf6x, lio->ifidx);
} else if (OCTEON_CN23XX_PF(oct)) { } else if (OCTEON_CN23XX_PF(oct)) {
struct octeon_config *conf23 = CHIP_FIELD(oct, cn23xx_pf, conf); struct octeon_config *conf23 = CHIP_CONF(oct, cn23xx_pf);
tx_max_pending = CN23XX_MAX_IQ_DESCRIPTORS; tx_max_pending = CN23XX_MAX_IQ_DESCRIPTORS;
rx_max_pending = CN23XX_MAX_OQ_DESCRIPTORS; rx_max_pending = CN23XX_MAX_OQ_DESCRIPTORS;
...@@ -757,9 +752,6 @@ lio_get_ethtool_stats(struct net_device *netdev, ...@@ -757,9 +752,6 @@ lio_get_ethtool_stats(struct net_device *netdev,
/*sum of oct->instr_queue[iq_no]->stats.tx_dropped */ /*sum of oct->instr_queue[iq_no]->stats.tx_dropped */
data[i++] = CVM_CAST64(netstats->tx_dropped); data[i++] = CVM_CAST64(netstats->tx_dropped);
/*data[i++] = CVM_CAST64(stats->multicast); */
/*data[i++] = CVM_CAST64(stats->collisions); */
/* firmware tx stats */ /* firmware tx stats */
/*per_core_stats[cvmx_get_core_num()].link_stats[mdata->from_ifidx]. /*per_core_stats[cvmx_get_core_num()].link_stats[mdata->from_ifidx].
*fromhost.fw_total_sent *fromhost.fw_total_sent
...@@ -910,9 +902,8 @@ lio_get_ethtool_stats(struct net_device *netdev, ...@@ -910,9 +902,8 @@ lio_get_ethtool_stats(struct net_device *netdev,
/*lio->link_changes*/ /*lio->link_changes*/
data[i++] = CVM_CAST64(lio->link_changes); data[i++] = CVM_CAST64(lio->link_changes);
/* TX -- lio_update_stats(lio); */
for (j = 0; j < MAX_OCTEON_INSTR_QUEUES(oct_dev); j++) { for (j = 0; j < MAX_OCTEON_INSTR_QUEUES(oct_dev); j++) {
if (!(oct_dev->io_qmask.iq & (1ULL << j))) if (!(oct_dev->io_qmask.iq & BIT_ULL(j)))
continue; continue;
/*packets to network port*/ /*packets to network port*/
/*# of packets tx to network */ /*# of packets tx to network */
...@@ -954,9 +945,8 @@ lio_get_ethtool_stats(struct net_device *netdev, ...@@ -954,9 +945,8 @@ lio_get_ethtool_stats(struct net_device *netdev,
} }
/* RX */ /* RX */
/* for (j = 0; j < oct_dev->num_oqs; j++) { */
for (j = 0; j < MAX_OCTEON_OUTPUT_QUEUES(oct_dev); j++) { for (j = 0; j < MAX_OCTEON_OUTPUT_QUEUES(oct_dev); j++) {
if (!(oct_dev->io_qmask.oq & (1ULL << j))) if (!(oct_dev->io_qmask.oq & BIT_ULL(j)))
continue; continue;
/*packets send to TCP/IP network stack */ /*packets send to TCP/IP network stack */
...@@ -1030,7 +1020,7 @@ static void lio_get_strings(struct net_device *netdev, u32 stringset, u8 *data) ...@@ -1030,7 +1020,7 @@ static void lio_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
num_iq_stats = ARRAY_SIZE(oct_iq_stats_strings); num_iq_stats = ARRAY_SIZE(oct_iq_stats_strings);
for (i = 0; i < MAX_OCTEON_INSTR_QUEUES(oct_dev); i++) { for (i = 0; i < MAX_OCTEON_INSTR_QUEUES(oct_dev); i++) {
if (!(oct_dev->io_qmask.iq & (1ULL << i))) if (!(oct_dev->io_qmask.iq & BIT_ULL(i)))
continue; continue;
for (j = 0; j < num_iq_stats; j++) { for (j = 0; j < num_iq_stats; j++) {
sprintf(data, "tx-%d-%s", i, sprintf(data, "tx-%d-%s", i,
...@@ -1040,9 +1030,8 @@ static void lio_get_strings(struct net_device *netdev, u32 stringset, u8 *data) ...@@ -1040,9 +1030,8 @@ static void lio_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
} }
num_oq_stats = ARRAY_SIZE(oct_droq_stats_strings); num_oq_stats = ARRAY_SIZE(oct_droq_stats_strings);
/* for (i = 0; i < oct_dev->num_oqs; i++) { */
for (i = 0; i < MAX_OCTEON_OUTPUT_QUEUES(oct_dev); i++) { for (i = 0; i < MAX_OCTEON_OUTPUT_QUEUES(oct_dev); i++) {
if (!(oct_dev->io_qmask.oq & (1ULL << i))) if (!(oct_dev->io_qmask.oq & BIT_ULL(i)))
continue; continue;
for (j = 0; j < num_oq_stats; j++) { for (j = 0; j < num_oq_stats; j++) {
sprintf(data, "rx-%d-%s", i, sprintf(data, "rx-%d-%s", i,
......
/********************************************************************** /**********************************************************************
* Author: Cavium, Inc. * Author: Cavium, Inc.
* *
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more details.
* details. ***********************************************************************/
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/
/*! \file liquidio_common.h /*! \file liquidio_common.h
* \brief Common: Structures and macros used in PCI-NIC package by core and * \brief Common: Structures and macros used in PCI-NIC package by core and
* host driver. * host driver.
...@@ -68,12 +63,10 @@ enum octeon_tag_type { ...@@ -68,12 +63,10 @@ enum octeon_tag_type {
*/ */
#define OPCODE_CORE 0 /* used for generic core operations */ #define OPCODE_CORE 0 /* used for generic core operations */
#define OPCODE_NIC 1 /* used for NIC operations */ #define OPCODE_NIC 1 /* used for NIC operations */
#define OPCODE_LAST OPCODE_NIC
/* Subcodes are used by host driver/apps to identify the sub-operation /* Subcodes are used by host driver/apps to identify the sub-operation
* for the core. They only need to by unique for a given subsystem. * for the core. They only need to by unique for a given subsystem.
*/ */
#define OPCODE_SUBCODE(op, sub) (((op & 0x0f) << 8) | ((sub) & 0x7f)) #define OPCODE_SUBCODE(op, sub) ((((op) & 0x0f) << 8) | ((sub) & 0x7f))
/** OPCODE_CORE subcodes. For future use. */ /** OPCODE_CORE subcodes. For future use. */
...@@ -89,13 +82,13 @@ enum octeon_tag_type { ...@@ -89,13 +82,13 @@ enum octeon_tag_type {
#define OPCODE_NIC_TIMESTAMP 0x07 #define OPCODE_NIC_TIMESTAMP 0x07
#define OPCODE_NIC_INTRMOD_CFG 0x08 #define OPCODE_NIC_INTRMOD_CFG 0x08
#define OPCODE_NIC_IF_CFG 0x09 #define OPCODE_NIC_IF_CFG 0x09
#define OPCODE_NIC_VF_DRV_NOTICE 0x0A
#define VF_DRV_LOADED 1
#define VF_DRV_REMOVED -1
#define VF_DRV_MACADDR_CHANGED 2
#define CORE_DRV_TEST_SCATTER_OP 0xFFF5 #define CORE_DRV_TEST_SCATTER_OP 0xFFF5
#define OPCODE_SLOW_PATH(rh) \
(OPCODE_SUBCODE(rh->r.opcode, rh->r.subcode) != \
OPCODE_SUBCODE(OPCODE_NIC, OPCODE_NIC_NW_DATA))
/* Application codes advertised by the core driver initialization packet. */ /* Application codes advertised by the core driver initialization packet. */
#define CVM_DRV_APP_START 0x0 #define CVM_DRV_APP_START 0x0
#define CVM_DRV_NO_APP 0 #define CVM_DRV_NO_APP 0
...@@ -105,31 +98,15 @@ enum octeon_tag_type { ...@@ -105,31 +98,15 @@ enum octeon_tag_type {
#define CVM_DRV_INVALID_APP (CVM_DRV_APP_START + 0x2) #define CVM_DRV_INVALID_APP (CVM_DRV_APP_START + 0x2)
#define CVM_DRV_APP_END (CVM_DRV_INVALID_APP - 1) #define CVM_DRV_APP_END (CVM_DRV_INVALID_APP - 1)
/* Macro to increment index. static inline u32 incr_index(u32 index, u32 count, u32 max)
* Index is incremented by count; if the sum exceeds {
* max, index is wrapped-around to the start. if ((index + count) >= max)
*/ index = index + count - max;
#define INCR_INDEX(index, count, max) \ else
do { \ index += count;
if (((index) + (count)) >= (max)) \
index = ((index) + (count)) - (max); \ return index;
else \ }
index += (count); \
} while (0)
#define INCR_INDEX_BY1(index, max) \
do { \
if ((++(index)) == (max)) \
index = 0; \
} while (0)
#define DECR_INDEX(index, count, max) \
do { \
if ((count) > (index)) \
index = ((max) - ((count - index))); \
else \
index -= count; \
} while (0)
#define OCT_BOARD_NAME 32 #define OCT_BOARD_NAME 32
#define OCT_SERIAL_LEN 64 #define OCT_SERIAL_LEN 64
...@@ -235,6 +212,7 @@ static inline void add_sg_size(struct octeon_sg_entry *sg_entry, ...@@ -235,6 +212,7 @@ static inline void add_sg_size(struct octeon_sg_entry *sg_entry,
#define OCTNET_CMD_ID_ACTIVE 0x1a #define OCTNET_CMD_ID_ACTIVE 0x1a
#define OCTNET_CMD_SET_VF_LINKSTATE 0x1c
#define OCTNET_CMD_VXLAN_PORT_ADD 0x0 #define OCTNET_CMD_VXLAN_PORT_ADD 0x0
#define OCTNET_CMD_VXLAN_PORT_DEL 0x1 #define OCTNET_CMD_VXLAN_PORT_DEL 0x1
#define OCTNET_CMD_RXCSUM_ENABLE 0x0 #define OCTNET_CMD_RXCSUM_ENABLE 0x0
...@@ -731,13 +709,15 @@ struct oct_link_info { ...@@ -731,13 +709,15 @@ struct oct_link_info {
#ifdef __BIG_ENDIAN_BITFIELD #ifdef __BIG_ENDIAN_BITFIELD
u64 gmxport:16; u64 gmxport:16;
u64 rsvd:32; u64 macaddr_is_admin_asgnd:1;
u64 rsvd:31;
u64 num_txpciq:8; u64 num_txpciq:8;
u64 num_rxpciq:8; u64 num_rxpciq:8;
#else #else
u64 num_rxpciq:8; u64 num_rxpciq:8;
u64 num_txpciq:8; u64 num_txpciq:8;
u64 rsvd:32; u64 rsvd:31;
u64 macaddr_is_admin_asgnd:1;
u64 gmxport:16; u64 gmxport:16;
#endif #endif
...@@ -827,6 +807,16 @@ struct oct_link_stats { ...@@ -827,6 +807,16 @@ struct oct_link_stats {
}; };
static inline int opcode_slow_path(union octeon_rh *rh)
{
u16 subcode1, subcode2;
subcode1 = OPCODE_SUBCODE((rh)->r.opcode, (rh)->r.subcode);
subcode2 = OPCODE_SUBCODE(OPCODE_NIC, OPCODE_NIC_NW_DATA);
return (subcode2 != subcode1);
}
#define LIO68XX_LED_CTRL_ADDR 0x3501 #define LIO68XX_LED_CTRL_ADDR 0x3501
#define LIO68XX_LED_CTRL_CFGON 0x1f #define LIO68XX_LED_CTRL_CFGON 0x1f
#define LIO68XX_LED_CTRL_CFGOFF 0x100 #define LIO68XX_LED_CTRL_CFGOFF 0x100
......
/********************************************************************** /**********************************************************************
* Author: Cavium, Inc. * Author: Cavium, Inc.
* *
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more details.
* details. ***********************************************************************/
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/
#ifndef _LIQUIDIO_IMAGE_H_ #ifndef _LIQUIDIO_IMAGE_H_
#define _LIQUIDIO_IMAGE_H_ #define _LIQUIDIO_IMAGE_H_
......
/********************************************************************** /**********************************************************************
* Author: Cavium, Inc. * Author: Cavium, Inc.
* *
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more details.
* details. ***********************************************************************/
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/
/*! \file octeon_config.h /*! \file octeon_config.h
* \brief Host Driver: Configuration data structures for the host driver. * \brief Host Driver: Configuration data structures for the host driver.
*/ */
...@@ -65,9 +60,15 @@ ...@@ -65,9 +60,15 @@
#define DEFAULT_NUM_NIC_PORTS_68XX_210NV 2 #define DEFAULT_NUM_NIC_PORTS_68XX_210NV 2
/* CN23xx IQ configuration macros */ /* CN23xx IQ configuration macros */
#define CN23XX_MAX_VFS_PER_PF_PASS_1_0 8
#define CN23XX_MAX_VFS_PER_PF_PASS_1_1 31
#define CN23XX_MAX_VFS_PER_PF 63
#define CN23XX_MAX_RINGS_PER_VF 8
#define CN23XX_MAX_RINGS_PER_PF_PASS_1_0 12 #define CN23XX_MAX_RINGS_PER_PF_PASS_1_0 12
#define CN23XX_MAX_RINGS_PER_PF_PASS_1_1 32 #define CN23XX_MAX_RINGS_PER_PF_PASS_1_1 32
#define CN23XX_MAX_RINGS_PER_PF 64 #define CN23XX_MAX_RINGS_PER_PF 64
#define CN23XX_MAX_RINGS_PER_VF 8
#define CN23XX_MAX_INPUT_QUEUES CN23XX_MAX_RINGS_PER_PF #define CN23XX_MAX_INPUT_QUEUES CN23XX_MAX_RINGS_PER_PF
#define CN23XX_MAX_IQ_DESCRIPTORS 2048 #define CN23XX_MAX_IQ_DESCRIPTORS 2048
...@@ -466,4 +467,7 @@ struct octeon_config { ...@@ -466,4 +467,7 @@ struct octeon_config {
#define MAX_POSSIBLE_OCTEON_INSTR_QUEUES CN23XX_MAX_INPUT_QUEUES #define MAX_POSSIBLE_OCTEON_INSTR_QUEUES CN23XX_MAX_INPUT_QUEUES
#define MAX_POSSIBLE_OCTEON_OUTPUT_QUEUES CN23XX_MAX_OUTPUT_QUEUES #define MAX_POSSIBLE_OCTEON_OUTPUT_QUEUES CN23XX_MAX_OUTPUT_QUEUES
#define MAX_POSSIBLE_VFS 64
#endif /* __OCTEON_CONFIG_H__ */ #endif /* __OCTEON_CONFIG_H__ */
/********************************************************************** /**********************************************************************
* Author: Cavium, Inc. * Author: Cavium, Inc.
* *
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more details.
* details. ***********************************************************************/
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/
/** /**
* @file octeon_console.c * @file octeon_console.c
*/ */
...@@ -76,9 +71,9 @@ MODULE_PARM_DESC(console_bitmask, ...@@ -76,9 +71,9 @@ MODULE_PARM_DESC(console_bitmask,
#define OCTEON_CONSOLE_POLL_INTERVAL_MS 100 /* 10 times per second */ #define OCTEON_CONSOLE_POLL_INTERVAL_MS 100 /* 10 times per second */
/* First three members of cvmx_bootmem_desc are left in original /* First three members of cvmx_bootmem_desc are left in original
** positions for backwards compatibility. * positions for backwards compatibility.
** Assumes big endian target * Assumes big endian target
*/ */
struct cvmx_bootmem_desc { struct cvmx_bootmem_desc {
/** spinlock to control access to list */ /** spinlock to control access to list */
u32 lock; u32 lock;
...@@ -142,46 +137,6 @@ struct octeon_pci_console_desc { ...@@ -142,46 +137,6 @@ struct octeon_pci_console_desc {
/* Implicit storage for console_addr_array */ /* Implicit storage for console_addr_array */
}; };
/**
* This macro returns the size of a member of a structure.
* Logically it is the same as "sizeof(s::field)" in C++, but
* C lacks the "::" operator.
*/
#define SIZEOF_FIELD(s, field) sizeof(((s *)NULL)->field)
/**
* This macro returns a member of the cvmx_bootmem_desc
* structure. These members can't be directly addressed as
* they might be in memory not directly reachable. In the case
* where bootmem is compiled with LINUX_HOST, the structure
* itself might be located on a remote Octeon. The argument
* "field" is the member name of the cvmx_bootmem_desc to read.
* Regardless of the type of the field, the return type is always
* a u64.
*/
#define CVMX_BOOTMEM_DESC_GET_FIELD(oct, field) \
__cvmx_bootmem_desc_get(oct, oct->bootmem_desc_addr, \
offsetof(struct cvmx_bootmem_desc, field), \
SIZEOF_FIELD(struct cvmx_bootmem_desc, field))
#define __cvmx_bootmem_lock(flags) (flags = flags)
#define __cvmx_bootmem_unlock(flags) (flags = flags)
/**
* This macro returns a member of the
* cvmx_bootmem_named_block_desc structure. These members can't
* be directly addressed as they might be in memory not directly
* reachable. In the case where bootmem is compiled with
* LINUX_HOST, the structure itself might be located on a remote
* Octeon. The argument "field" is the member name of the
* cvmx_bootmem_named_block_desc to read. Regardless of the type
* of the field, the return type is always a u64. The "addr"
* parameter is the physical address of the structure.
*/
#define CVMX_BOOTMEM_NAMED_GET_FIELD(oct, addr, field) \
__cvmx_bootmem_desc_get(oct, addr, \
offsetof(struct cvmx_bootmem_named_block_desc, field), \
SIZEOF_FIELD(struct cvmx_bootmem_named_block_desc, field))
/** /**
* \brief determines if a given console has debug enabled. * \brief determines if a given console has debug enabled.
* @param console console to check * @param console console to check
...@@ -263,10 +218,15 @@ static int __cvmx_bootmem_check_version(struct octeon_device *oct, ...@@ -263,10 +218,15 @@ static int __cvmx_bootmem_check_version(struct octeon_device *oct,
oct->bootmem_desc_addr = oct->bootmem_desc_addr =
octeon_read_device_mem64(oct, octeon_read_device_mem64(oct,
BOOTLOADER_PCI_READ_DESC_ADDR); BOOTLOADER_PCI_READ_DESC_ADDR);
major_version = major_version = (u32)__cvmx_bootmem_desc_get(
(u32)CVMX_BOOTMEM_DESC_GET_FIELD(oct, major_version); oct, oct->bootmem_desc_addr,
minor_version = offsetof(struct cvmx_bootmem_desc, major_version),
(u32)CVMX_BOOTMEM_DESC_GET_FIELD(oct, minor_version); FIELD_SIZEOF(struct cvmx_bootmem_desc, major_version));
minor_version = (u32)__cvmx_bootmem_desc_get(
oct, oct->bootmem_desc_addr,
offsetof(struct cvmx_bootmem_desc, minor_version),
FIELD_SIZEOF(struct cvmx_bootmem_desc, minor_version));
dev_dbg(&oct->pci_dev->dev, "%s: major_version=%d\n", __func__, dev_dbg(&oct->pci_dev->dev, "%s: major_version=%d\n", __func__,
major_version); major_version);
if ((major_version > 3) || if ((major_version > 3) ||
...@@ -289,10 +249,20 @@ static const struct cvmx_bootmem_named_block_desc ...@@ -289,10 +249,20 @@ static const struct cvmx_bootmem_named_block_desc
u64 named_addr = cvmx_bootmem_phy_named_block_find(oct, name, flags); u64 named_addr = cvmx_bootmem_phy_named_block_find(oct, name, flags);
if (named_addr) { if (named_addr) {
desc->base_addr = CVMX_BOOTMEM_NAMED_GET_FIELD(oct, named_addr, desc->base_addr = __cvmx_bootmem_desc_get(
base_addr); oct, named_addr,
desc->size = offsetof(struct cvmx_bootmem_named_block_desc,
CVMX_BOOTMEM_NAMED_GET_FIELD(oct, named_addr, size); base_addr),
FIELD_SIZEOF(
struct cvmx_bootmem_named_block_desc,
base_addr));
desc->size = __cvmx_bootmem_desc_get(oct, named_addr,
offsetof(struct cvmx_bootmem_named_block_desc,
size),
FIELD_SIZEOF(
struct cvmx_bootmem_named_block_desc,
size));
strncpy(desc->name, name, sizeof(desc->name)); strncpy(desc->name, name, sizeof(desc->name));
desc->name[sizeof(desc->name) - 1] = 0; desc->name[sizeof(desc->name) - 1] = 0;
return &oct->bootmem_named_block_desc; return &oct->bootmem_named_block_desc;
...@@ -307,22 +277,41 @@ static u64 cvmx_bootmem_phy_named_block_find(struct octeon_device *oct, ...@@ -307,22 +277,41 @@ static u64 cvmx_bootmem_phy_named_block_find(struct octeon_device *oct,
{ {
u64 result = 0; u64 result = 0;
__cvmx_bootmem_lock(flags);
if (!__cvmx_bootmem_check_version(oct, 3)) { if (!__cvmx_bootmem_check_version(oct, 3)) {
u32 i; u32 i;
u64 named_block_array_addr =
CVMX_BOOTMEM_DESC_GET_FIELD(oct, u64 named_block_array_addr = __cvmx_bootmem_desc_get(
named_block_array_addr); oct, oct->bootmem_desc_addr,
u32 num_blocks = (u32) offsetof(struct cvmx_bootmem_desc,
CVMX_BOOTMEM_DESC_GET_FIELD(oct, nb_num_blocks); named_block_array_addr),
u32 name_length = (u32) FIELD_SIZEOF(struct cvmx_bootmem_desc,
CVMX_BOOTMEM_DESC_GET_FIELD(oct, named_block_name_len); named_block_array_addr));
u32 num_blocks = (u32)__cvmx_bootmem_desc_get(
oct, oct->bootmem_desc_addr,
offsetof(struct cvmx_bootmem_desc,
nb_num_blocks),
FIELD_SIZEOF(struct cvmx_bootmem_desc,
nb_num_blocks));
u32 name_length = (u32)__cvmx_bootmem_desc_get(
oct, oct->bootmem_desc_addr,
offsetof(struct cvmx_bootmem_desc,
named_block_name_len),
FIELD_SIZEOF(struct cvmx_bootmem_desc,
named_block_name_len));
u64 named_addr = named_block_array_addr; u64 named_addr = named_block_array_addr;
for (i = 0; i < num_blocks; i++) { for (i = 0; i < num_blocks; i++) {
u64 named_size = u64 named_size = __cvmx_bootmem_desc_get(
CVMX_BOOTMEM_NAMED_GET_FIELD(oct, named_addr, oct, named_addr,
size); offsetof(
struct cvmx_bootmem_named_block_desc,
size),
FIELD_SIZEOF(
struct cvmx_bootmem_named_block_desc,
size));
if (name && named_size) { if (name && named_size) {
char *name_tmp = char *name_tmp =
kmalloc(name_length + 1, GFP_KERNEL); kmalloc(name_length + 1, GFP_KERNEL);
...@@ -347,7 +336,6 @@ static u64 cvmx_bootmem_phy_named_block_find(struct octeon_device *oct, ...@@ -347,7 +336,6 @@ static u64 cvmx_bootmem_phy_named_block_find(struct octeon_device *oct,
sizeof(struct cvmx_bootmem_named_block_desc); sizeof(struct cvmx_bootmem_named_block_desc);
} }
} }
__cvmx_bootmem_unlock(flags);
return result; return result;
} }
......
/********************************************************************** /**********************************************************************
* Author: Cavium, Inc. * Author: Cavium, Inc.
* *
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more details.
* details. ***********************************************************************/
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
...@@ -520,11 +516,6 @@ static struct octeon_config default_cn23xx_conf = { ...@@ -520,11 +516,6 @@ static struct octeon_config default_cn23xx_conf = {
} }
}; };
enum {
OCTEON_CONFIG_TYPE_DEFAULT = 0,
NUM_OCTEON_CONFS,
};
static struct octeon_config_ptr { static struct octeon_config_ptr {
u32 conf_type; u32 conf_type;
} oct_conf_info[MAX_OCTEON_DEVICES] = { } oct_conf_info[MAX_OCTEON_DEVICES] = {
...@@ -649,12 +640,12 @@ void octeon_free_device_mem(struct octeon_device *oct) ...@@ -649,12 +640,12 @@ void octeon_free_device_mem(struct octeon_device *oct)
int i; int i;
for (i = 0; i < MAX_OCTEON_OUTPUT_QUEUES(oct); i++) { for (i = 0; i < MAX_OCTEON_OUTPUT_QUEUES(oct); i++) {
if (oct->io_qmask.oq & (1ULL << i)) if (oct->io_qmask.oq & BIT_ULL(i))
vfree(oct->droq[i]); vfree(oct->droq[i]);
} }
for (i = 0; i < MAX_OCTEON_INSTR_QUEUES(oct); i++) { for (i = 0; i < MAX_OCTEON_INSTR_QUEUES(oct); i++) {
if (oct->io_qmask.iq & (1ULL << i)) if (oct->io_qmask.iq & BIT_ULL(i))
vfree(oct->instr_queue[i]); vfree(oct->instr_queue[i]);
} }
...@@ -767,6 +758,7 @@ octeon_allocate_ioq_vector(struct octeon_device *oct) ...@@ -767,6 +758,7 @@ octeon_allocate_ioq_vector(struct octeon_device *oct)
ioq_vector->oct_dev = oct; ioq_vector->oct_dev = oct;
ioq_vector->iq_index = i; ioq_vector->iq_index = i;
ioq_vector->droq_index = i; ioq_vector->droq_index = i;
ioq_vector->mbox = oct->mbox[i];
cpu_num = i % num_online_cpus(); cpu_num = i % num_online_cpus();
cpumask_set_cpu(cpu_num, &ioq_vector->affinity_mask); cpumask_set_cpu(cpu_num, &ioq_vector->affinity_mask);
...@@ -795,10 +787,9 @@ int octeon_setup_instr_queues(struct octeon_device *oct) ...@@ -795,10 +787,9 @@ int octeon_setup_instr_queues(struct octeon_device *oct)
if (OCTEON_CN6XXX(oct)) if (OCTEON_CN6XXX(oct))
num_descs = num_descs =
CFG_GET_NUM_DEF_TX_DESCS(CHIP_FIELD(oct, cn6xxx, conf)); CFG_GET_NUM_DEF_TX_DESCS(CHIP_CONF(oct, cn6xxx));
else if (OCTEON_CN23XX_PF(oct)) else if (OCTEON_CN23XX_PF(oct))
num_descs = CFG_GET_NUM_DEF_TX_DESCS(CHIP_FIELD(oct, cn23xx_pf, num_descs = CFG_GET_NUM_DEF_TX_DESCS(CHIP_CONF(oct, cn23xx_pf));
conf));
oct->num_iqs = 0; oct->num_iqs = 0;
...@@ -821,6 +812,7 @@ int octeon_setup_instr_queues(struct octeon_device *oct) ...@@ -821,6 +812,7 @@ int octeon_setup_instr_queues(struct octeon_device *oct)
if (octeon_init_instr_queue(oct, txpciq, num_descs)) { if (octeon_init_instr_queue(oct, txpciq, num_descs)) {
/* prevent memory leak */ /* prevent memory leak */
vfree(oct->instr_queue[0]); vfree(oct->instr_queue[0]);
oct->instr_queue[0] = NULL;
return 1; return 1;
} }
...@@ -837,14 +829,12 @@ int octeon_setup_output_queues(struct octeon_device *oct) ...@@ -837,14 +829,12 @@ int octeon_setup_output_queues(struct octeon_device *oct)
if (OCTEON_CN6XXX(oct)) { if (OCTEON_CN6XXX(oct)) {
num_descs = num_descs =
CFG_GET_NUM_DEF_RX_DESCS(CHIP_FIELD(oct, cn6xxx, conf)); CFG_GET_NUM_DEF_RX_DESCS(CHIP_CONF(oct, cn6xxx));
desc_size = desc_size =
CFG_GET_DEF_RX_BUF_SIZE(CHIP_FIELD(oct, cn6xxx, conf)); CFG_GET_DEF_RX_BUF_SIZE(CHIP_CONF(oct, cn6xxx));
} else if (OCTEON_CN23XX_PF(oct)) { } else if (OCTEON_CN23XX_PF(oct)) {
num_descs = CFG_GET_NUM_DEF_RX_DESCS(CHIP_FIELD(oct, cn23xx_pf, num_descs = CFG_GET_NUM_DEF_RX_DESCS(CHIP_CONF(oct, cn23xx_pf));
conf)); desc_size = CFG_GET_DEF_RX_BUF_SIZE(CHIP_CONF(oct, cn23xx_pf));
desc_size = CFG_GET_DEF_RX_BUF_SIZE(CHIP_FIELD(oct, cn23xx_pf,
conf));
} }
oct->num_oqs = 0; oct->num_oqs = 0;
oct->droq[0] = vmalloc_node(sizeof(*oct->droq[0]), numa_node); oct->droq[0] = vmalloc_node(sizeof(*oct->droq[0]), numa_node);
...@@ -853,8 +843,11 @@ int octeon_setup_output_queues(struct octeon_device *oct) ...@@ -853,8 +843,11 @@ int octeon_setup_output_queues(struct octeon_device *oct)
if (!oct->droq[0]) if (!oct->droq[0])
return 1; return 1;
if (octeon_init_droq(oct, oq_no, num_descs, desc_size, NULL)) if (octeon_init_droq(oct, oq_no, num_descs, desc_size, NULL)) {
vfree(oct->droq[oq_no]);
oct->droq[oq_no] = NULL;
return 1; return 1;
}
oct->num_oqs++; oct->num_oqs++;
return 0; return 0;
...@@ -1070,10 +1063,10 @@ int octeon_core_drv_init(struct octeon_recv_info *recv_info, void *buf) ...@@ -1070,10 +1063,10 @@ int octeon_core_drv_init(struct octeon_recv_info *recv_info, void *buf)
if (OCTEON_CN6XXX(oct)) if (OCTEON_CN6XXX(oct))
num_nic_ports = num_nic_ports =
CFG_GET_NUM_NIC_PORTS(CHIP_FIELD(oct, cn6xxx, conf)); CFG_GET_NUM_NIC_PORTS(CHIP_CONF(oct, cn6xxx));
else if (OCTEON_CN23XX_PF(oct)) else if (OCTEON_CN23XX_PF(oct))
num_nic_ports = num_nic_ports =
CFG_GET_NUM_NIC_PORTS(CHIP_FIELD(oct, cn23xx_pf, conf)); CFG_GET_NUM_NIC_PORTS(CHIP_CONF(oct, cn23xx_pf));
if (atomic_read(&oct->status) >= OCT_DEV_RUNNING) { if (atomic_read(&oct->status) >= OCT_DEV_RUNNING) {
dev_err(&oct->pci_dev->dev, "Received CORE OK when device state is 0x%x\n", dev_err(&oct->pci_dev->dev, "Received CORE OK when device state is 0x%x\n",
...@@ -1143,7 +1136,7 @@ int octeon_get_tx_qsize(struct octeon_device *oct, u32 q_no) ...@@ -1143,7 +1136,7 @@ int octeon_get_tx_qsize(struct octeon_device *oct, u32 q_no)
{ {
if (oct && (q_no < MAX_OCTEON_INSTR_QUEUES(oct)) && if (oct && (q_no < MAX_OCTEON_INSTR_QUEUES(oct)) &&
(oct->io_qmask.iq & (1ULL << q_no))) (oct->io_qmask.iq & BIT_ULL(q_no)))
return oct->instr_queue[q_no]->max_count; return oct->instr_queue[q_no]->max_count;
return -1; return -1;
...@@ -1152,7 +1145,7 @@ int octeon_get_tx_qsize(struct octeon_device *oct, u32 q_no) ...@@ -1152,7 +1145,7 @@ int octeon_get_tx_qsize(struct octeon_device *oct, u32 q_no)
int octeon_get_rx_qsize(struct octeon_device *oct, u32 q_no) int octeon_get_rx_qsize(struct octeon_device *oct, u32 q_no)
{ {
if (oct && (q_no < MAX_OCTEON_OUTPUT_QUEUES(oct)) && if (oct && (q_no < MAX_OCTEON_OUTPUT_QUEUES(oct)) &&
(oct->io_qmask.oq & (1ULL << q_no))) (oct->io_qmask.oq & BIT_ULL(q_no)))
return oct->droq[q_no]->max_count; return oct->droq[q_no]->max_count;
return -1; return -1;
} }
...@@ -1168,10 +1161,10 @@ struct octeon_config *octeon_get_conf(struct octeon_device *oct) ...@@ -1168,10 +1161,10 @@ struct octeon_config *octeon_get_conf(struct octeon_device *oct)
if (OCTEON_CN6XXX(oct)) { if (OCTEON_CN6XXX(oct)) {
default_oct_conf = default_oct_conf =
(struct octeon_config *)(CHIP_FIELD(oct, cn6xxx, conf)); (struct octeon_config *)(CHIP_CONF(oct, cn6xxx));
} else if (OCTEON_CN23XX_PF(oct)) { } else if (OCTEON_CN23XX_PF(oct)) {
default_oct_conf = (struct octeon_config *) default_oct_conf = (struct octeon_config *)
(CHIP_FIELD(oct, cn23xx_pf, conf)); (CHIP_CONF(oct, cn23xx_pf));
} }
return default_oct_conf; return default_oct_conf;
} }
......
/********************************************************************** /**********************************************************************
* Author: Cavium, Inc. * Author: Cavium, Inc.
* *
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more details.
* details. ***********************************************************************/
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/
/*! \file octeon_device.h /*! \file octeon_device.h
* \brief Host Driver: This file defines the octeon device structure. * \brief Host Driver: This file defines the octeon device structure.
*/ */
...@@ -38,6 +33,7 @@ ...@@ -38,6 +33,7 @@
#define OCTEON_CN68XX 0x0091 #define OCTEON_CN68XX 0x0091
#define OCTEON_CN66XX 0x0092 #define OCTEON_CN66XX 0x0092
#define OCTEON_CN23XX_PF_VID 0x9702 #define OCTEON_CN23XX_PF_VID 0x9702
#define OCTEON_CN23XX_VF_VID 0x9712
/**RevisionId for the chips */ /**RevisionId for the chips */
#define OCTEON_CN23XX_REV_1_0 0x00 #define OCTEON_CN23XX_REV_1_0 0x00
...@@ -52,7 +48,13 @@ enum octeon_pci_swap_mode { ...@@ -52,7 +48,13 @@ enum octeon_pci_swap_mode {
OCTEON_PCI_32BIT_LW_SWAP = 3 OCTEON_PCI_32BIT_LW_SWAP = 3
}; };
enum {
OCTEON_CONFIG_TYPE_DEFAULT = 0,
NUM_OCTEON_CONFS,
};
#define OCTEON_OUTPUT_INTR (2) #define OCTEON_OUTPUT_INTR (2)
#define OCTEON_MBOX_INTR (4)
#define OCTEON_ALL_INTR 0xff #define OCTEON_ALL_INTR 0xff
/*--------------- PCI BAR1 index registers -------------*/ /*--------------- PCI BAR1 index registers -------------*/
...@@ -70,19 +72,23 @@ enum octeon_pci_swap_mode { ...@@ -70,19 +72,23 @@ enum octeon_pci_swap_mode {
* as it is initialized. * as it is initialized.
*/ */
#define OCT_DEV_BEGIN_STATE 0x0 #define OCT_DEV_BEGIN_STATE 0x0
#define OCT_DEV_PCI_MAP_DONE 0x1 #define OCT_DEV_PCI_ENABLE_DONE 0x1
#define OCT_DEV_DISPATCH_INIT_DONE 0x2 #define OCT_DEV_PCI_MAP_DONE 0x2
#define OCT_DEV_INSTR_QUEUE_INIT_DONE 0x3 #define OCT_DEV_DISPATCH_INIT_DONE 0x3
#define OCT_DEV_SC_BUFF_POOL_INIT_DONE 0x4 #define OCT_DEV_INSTR_QUEUE_INIT_DONE 0x4
#define OCT_DEV_RESP_LIST_INIT_DONE 0x5 #define OCT_DEV_SC_BUFF_POOL_INIT_DONE 0x5
#define OCT_DEV_DROQ_INIT_DONE 0x6 #define OCT_DEV_RESP_LIST_INIT_DONE 0x6
#define OCT_DEV_IO_QUEUES_DONE 0x7 #define OCT_DEV_DROQ_INIT_DONE 0x7
#define OCT_DEV_CONSOLE_INIT_DONE 0x8 #define OCT_DEV_MBOX_SETUP_DONE 0x8
#define OCT_DEV_HOST_OK 0x9 #define OCT_DEV_MSIX_ALLOC_VECTOR_DONE 0x9
#define OCT_DEV_CORE_OK 0xa #define OCT_DEV_INTR_SET_DONE 0xa
#define OCT_DEV_RUNNING 0xb #define OCT_DEV_IO_QUEUES_DONE 0xb
#define OCT_DEV_IN_RESET 0xc #define OCT_DEV_CONSOLE_INIT_DONE 0xc
#define OCT_DEV_STATE_INVALID 0xd #define OCT_DEV_HOST_OK 0xd
#define OCT_DEV_CORE_OK 0xe
#define OCT_DEV_RUNNING 0xf
#define OCT_DEV_IN_RESET 0x10
#define OCT_DEV_STATE_INVALID 0x11
#define OCT_DEV_STATES OCT_DEV_STATE_INVALID #define OCT_DEV_STATES OCT_DEV_STATE_INVALID
...@@ -208,6 +214,10 @@ struct octeon_fn_list { ...@@ -208,6 +214,10 @@ struct octeon_fn_list {
irqreturn_t (*process_interrupt_regs)(void *); irqreturn_t (*process_interrupt_regs)(void *);
u64 (*msix_interrupt_handler)(void *); u64 (*msix_interrupt_handler)(void *);
int (*setup_mbox)(struct octeon_device *);
int (*free_mbox)(struct octeon_device *);
int (*soft_reset)(struct octeon_device *); int (*soft_reset)(struct octeon_device *);
int (*setup_device_regs)(struct octeon_device *); int (*setup_device_regs)(struct octeon_device *);
void (*bar1_idx_setup)(struct octeon_device *, u64, u32, int); void (*bar1_idx_setup)(struct octeon_device *, u64, u32, int);
...@@ -322,14 +332,39 @@ struct octeon_pf_vf_hs_word { ...@@ -322,14 +332,39 @@ struct octeon_pf_vf_hs_word {
}; };
struct octeon_sriov_info { struct octeon_sriov_info {
/* Number of rings assigned to VF */
u32 rings_per_vf;
/** Max Number of VF devices that can be enabled. This variable can
* specified during load time or it will be derived after allocating
* PF queues. When max_vfs is derived then each VF will get one queue
**/
u32 max_vfs;
/** Number of VF devices enabled using sysfs. */
u32 num_vfs_alloced;
/* Actual rings left for PF device */ /* Actual rings left for PF device */
u32 num_pf_rings; u32 num_pf_rings;
/* SRN of PF usable IO queues */ /* SRN of PF usable IO queues */
u32 pf_srn; u32 pf_srn;
/* total pf rings */ /* total pf rings */
u32 trs; u32 trs;
u32 sriov_enabled;
/*lookup table that maps DPI ring number to VF pci_dev struct pointer*/
struct pci_dev *dpiring_to_vfpcidev_lut[MAX_POSSIBLE_VFS];
u64 vf_macaddr[MAX_POSSIBLE_VFS];
u16 vf_vlantci[MAX_POSSIBLE_VFS];
int vf_linkstate[MAX_POSSIBLE_VFS];
u64 vf_drv_loaded_mask;
}; };
struct octeon_ioq_vector { struct octeon_ioq_vector {
...@@ -337,6 +372,7 @@ struct octeon_ioq_vector { ...@@ -337,6 +372,7 @@ struct octeon_ioq_vector {
int iq_index; int iq_index;
int droq_index; int droq_index;
int vector; int vector;
struct octeon_mbox *mbox;
struct cpumask affinity_mask; struct cpumask affinity_mask;
u32 ioq_num; u32 ioq_num;
}; };
...@@ -474,6 +510,9 @@ struct octeon_device { ...@@ -474,6 +510,9 @@ struct octeon_device {
int msix_on; int msix_on;
/** Mail Box details of each octeon queue. */
struct octeon_mbox *mbox[MAX_POSSIBLE_VFS];
/** IOq information of it's corresponding MSI-X interrupt. */ /** IOq information of it's corresponding MSI-X interrupt. */
struct octeon_ioq_vector *ioq_vector; struct octeon_ioq_vector *ioq_vector;
...@@ -490,11 +529,14 @@ struct octeon_device { ...@@ -490,11 +529,14 @@ struct octeon_device {
#define OCT_DRV_ONLINE 1 #define OCT_DRV_ONLINE 1
#define OCT_DRV_OFFLINE 2 #define OCT_DRV_OFFLINE 2
#define OCTEON_CN6XXX(oct) ((oct->chip_id == OCTEON_CN66XX) || \ #define OCTEON_CN6XXX(oct) ({ \
(oct->chip_id == OCTEON_CN68XX)) typeof(oct) _oct = (oct); \
#define OCTEON_CN23XX_PF(oct) (oct->chip_id == OCTEON_CN23XX_PF_VID) ((_oct->chip_id == OCTEON_CN66XX) || \
#define CHIP_FIELD(oct, TYPE, field) \ (_oct->chip_id == OCTEON_CN68XX)); })
(((struct octeon_ ## TYPE *)(oct->chip))->field) #define OCTEON_CN23XX_PF(oct) ((oct)->chip_id == OCTEON_CN23XX_PF_VID)
#define OCTEON_CN23XX_VF(oct) ((oct)->chip_id == OCTEON_CN23XX_VF_VID)
#define CHIP_CONF(oct, TYPE) \
(((struct octeon_ ## TYPE *)((oct)->chip))->conf)
struct oct_intrmod_cmd { struct oct_intrmod_cmd {
struct octeon_device *oct_dev; struct octeon_device *oct_dev;
...@@ -508,7 +550,7 @@ struct oct_intrmod_cmd { ...@@ -508,7 +550,7 @@ struct oct_intrmod_cmd {
void octeon_init_device_list(int conf_type); void octeon_init_device_list(int conf_type);
/** Free memory for Input and Output queue structures for a octeon device */ /** Free memory for Input and Output queue structures for a octeon device */
void octeon_free_device_mem(struct octeon_device *); void octeon_free_device_mem(struct octeon_device *oct);
/* Look up a free entry in the octeon_device table and allocate resources /* Look up a free entry in the octeon_device table and allocate resources
* for the octeon_device structure for an octeon device. Called at init * for the octeon_device structure for an octeon device. Called at init
...@@ -606,16 +648,16 @@ void lio_pci_writeq(struct octeon_device *oct, u64 val, u64 addr); ...@@ -606,16 +648,16 @@ void lio_pci_writeq(struct octeon_device *oct, u64 val, u64 addr);
/* Routines for reading and writing CSRs */ /* Routines for reading and writing CSRs */
#define octeon_write_csr(oct_dev, reg_off, value) \ #define octeon_write_csr(oct_dev, reg_off, value) \
writel(value, oct_dev->mmio[0].hw_addr + reg_off) writel(value, (oct_dev)->mmio[0].hw_addr + (reg_off))
#define octeon_write_csr64(oct_dev, reg_off, val64) \ #define octeon_write_csr64(oct_dev, reg_off, val64) \
writeq(val64, oct_dev->mmio[0].hw_addr + reg_off) writeq(val64, (oct_dev)->mmio[0].hw_addr + (reg_off))
#define octeon_read_csr(oct_dev, reg_off) \ #define octeon_read_csr(oct_dev, reg_off) \
readl(oct_dev->mmio[0].hw_addr + reg_off) readl((oct_dev)->mmio[0].hw_addr + (reg_off))
#define octeon_read_csr64(oct_dev, reg_off) \ #define octeon_read_csr64(oct_dev, reg_off) \
readq(oct_dev->mmio[0].hw_addr + reg_off) readq((oct_dev)->mmio[0].hw_addr + (reg_off))
/** /**
* Checks if memory access is okay * Checks if memory access is okay
......
/********************************************************************** /**********************************************************************
* Author: Cavium, Inc. * Author: Cavium, Inc.
* *
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more details.
* details. ***********************************************************************/
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
...@@ -33,9 +29,6 @@ ...@@ -33,9 +29,6 @@
#include "cn66xx_device.h" #include "cn66xx_device.h"
#include "cn23xx_pf_device.h" #include "cn23xx_pf_device.h"
#define CVM_MIN(d1, d2) (((d1) < (d2)) ? (d1) : (d2))
#define CVM_MAX(d1, d2) (((d1) > (d2)) ? (d1) : (d2))
struct niclist { struct niclist {
struct list_head list; struct list_head list;
void *ptr; void *ptr;
...@@ -258,13 +251,13 @@ int octeon_init_droq(struct octeon_device *oct, ...@@ -258,13 +251,13 @@ int octeon_init_droq(struct octeon_device *oct,
c_num_descs = num_descs; c_num_descs = num_descs;
c_buf_size = desc_size; c_buf_size = desc_size;
if (OCTEON_CN6XXX(oct)) { if (OCTEON_CN6XXX(oct)) {
struct octeon_config *conf6x = CHIP_FIELD(oct, cn6xxx, conf); struct octeon_config *conf6x = CHIP_CONF(oct, cn6xxx);
c_pkts_per_intr = (u32)CFG_GET_OQ_PKTS_PER_INTR(conf6x); c_pkts_per_intr = (u32)CFG_GET_OQ_PKTS_PER_INTR(conf6x);
c_refill_threshold = c_refill_threshold =
(u32)CFG_GET_OQ_REFILL_THRESHOLD(conf6x); (u32)CFG_GET_OQ_REFILL_THRESHOLD(conf6x);
} else if (OCTEON_CN23XX_PF(oct)) { } else if (OCTEON_CN23XX_PF(oct)) {
struct octeon_config *conf23 = CHIP_FIELD(oct, cn23xx_pf, conf); struct octeon_config *conf23 = CHIP_CONF(oct, cn23xx_pf);
c_pkts_per_intr = (u32)CFG_GET_OQ_PKTS_PER_INTR(conf23); c_pkts_per_intr = (u32)CFG_GET_OQ_PKTS_PER_INTR(conf23);
c_refill_threshold = (u32)CFG_GET_OQ_REFILL_THRESHOLD(conf23); c_refill_threshold = (u32)CFG_GET_OQ_REFILL_THRESHOLD(conf23);
...@@ -337,7 +330,7 @@ int octeon_init_droq(struct octeon_device *oct, ...@@ -337,7 +330,7 @@ int octeon_init_droq(struct octeon_device *oct,
/* For 56xx Pass1, this function won't be called, so no checks. */ /* For 56xx Pass1, this function won't be called, so no checks. */
oct->fn_list.setup_oq_regs(oct, q_no); oct->fn_list.setup_oq_regs(oct, q_no);
oct->io_qmask.oq |= (1ULL << q_no); oct->io_qmask.oq |= BIT_ULL(q_no);
return 0; return 0;
...@@ -409,7 +402,7 @@ static inline struct octeon_recv_info *octeon_create_recv_info( ...@@ -409,7 +402,7 @@ static inline struct octeon_recv_info *octeon_create_recv_info(
recv_pkt->buffer_ptr[i] = droq->recv_buf_list[idx].buffer; recv_pkt->buffer_ptr[i] = droq->recv_buf_list[idx].buffer;
droq->recv_buf_list[idx].buffer = NULL; droq->recv_buf_list[idx].buffer = NULL;
INCR_INDEX_BY1(idx, droq->max_count); idx = incr_index(idx, 1, droq->max_count);
bytes_left -= droq->buffer_size; bytes_left -= droq->buffer_size;
i++; i++;
buf_cnt--; buf_cnt--;
...@@ -440,14 +433,15 @@ octeon_droq_refill_pullup_descs(struct octeon_droq *droq, ...@@ -440,14 +433,15 @@ octeon_droq_refill_pullup_descs(struct octeon_droq *droq,
droq->recv_buf_list[refill_index].buffer = NULL; droq->recv_buf_list[refill_index].buffer = NULL;
desc_ring[refill_index].buffer_ptr = 0; desc_ring[refill_index].buffer_ptr = 0;
do { do {
INCR_INDEX_BY1(droq->refill_idx, droq->refill_idx = incr_index(droq->refill_idx,
1,
droq->max_count); droq->max_count);
desc_refilled++; desc_refilled++;
droq->refill_count--; droq->refill_count--;
} while (droq->recv_buf_list[droq->refill_idx]. } while (droq->recv_buf_list[droq->refill_idx].
buffer); buffer);
} }
INCR_INDEX_BY1(refill_index, droq->max_count); refill_index = incr_index(refill_index, 1, droq->max_count);
} /* while */ } /* while */
return desc_refilled; return desc_refilled;
} }
...@@ -514,7 +508,8 @@ octeon_droq_refill(struct octeon_device *octeon_dev, struct octeon_droq *droq) ...@@ -514,7 +508,8 @@ octeon_droq_refill(struct octeon_device *octeon_dev, struct octeon_droq *droq)
/* Reset any previous values in the length field. */ /* Reset any previous values in the length field. */
droq->info_list[droq->refill_idx].length = 0; droq->info_list[droq->refill_idx].length = 0;
INCR_INDEX_BY1(droq->refill_idx, droq->max_count); droq->refill_idx = incr_index(droq->refill_idx, 1,
droq->max_count);
desc_refilled++; desc_refilled++;
droq->refill_count--; droq->refill_count--;
} }
...@@ -599,7 +594,8 @@ static inline void octeon_droq_drop_packets(struct octeon_device *oct, ...@@ -599,7 +594,8 @@ static inline void octeon_droq_drop_packets(struct octeon_device *oct,
buf_cnt = 1; buf_cnt = 1;
} }
INCR_INDEX(droq->read_idx, buf_cnt, droq->max_count); droq->read_idx = incr_index(droq->read_idx, buf_cnt,
droq->max_count);
droq->refill_count += buf_cnt; droq->refill_count += buf_cnt;
} }
} }
...@@ -639,11 +635,12 @@ octeon_droq_fast_process_packets(struct octeon_device *oct, ...@@ -639,11 +635,12 @@ octeon_droq_fast_process_packets(struct octeon_device *oct,
rh = &info->rh; rh = &info->rh;
total_len += (u32)info->length; total_len += (u32)info->length;
if (OPCODE_SLOW_PATH(rh)) { if (opcode_slow_path(rh)) {
u32 buf_cnt; u32 buf_cnt;
buf_cnt = octeon_droq_dispatch_pkt(oct, droq, rh, info); buf_cnt = octeon_droq_dispatch_pkt(oct, droq, rh, info);
INCR_INDEX(droq->read_idx, buf_cnt, droq->max_count); droq->read_idx = incr_index(droq->read_idx,
buf_cnt, droq->max_count);
droq->refill_count += buf_cnt; droq->refill_count += buf_cnt;
} else { } else {
if (info->length <= droq->buffer_size) { if (info->length <= droq->buffer_size) {
...@@ -657,7 +654,8 @@ octeon_droq_fast_process_packets(struct octeon_device *oct, ...@@ -657,7 +654,8 @@ octeon_droq_fast_process_packets(struct octeon_device *oct,
droq->recv_buf_list[droq->read_idx].buffer = droq->recv_buf_list[droq->read_idx].buffer =
NULL; NULL;
INCR_INDEX_BY1(droq->read_idx, droq->max_count); droq->read_idx = incr_index(droq->read_idx, 1,
droq->max_count);
droq->refill_count++; droq->refill_count++;
} else { } else {
nicbuf = octeon_fast_packet_alloc((u32) nicbuf = octeon_fast_packet_alloc((u32)
...@@ -689,7 +687,8 @@ octeon_droq_fast_process_packets(struct octeon_device *oct, ...@@ -689,7 +687,8 @@ octeon_droq_fast_process_packets(struct octeon_device *oct,
} }
pkt_len += cpy_len; pkt_len += cpy_len;
INCR_INDEX_BY1(droq->read_idx, droq->read_idx =
incr_index(droq->read_idx, 1,
droq->max_count); droq->max_count);
droq->refill_count++; droq->refill_count++;
} }
...@@ -804,8 +803,7 @@ octeon_droq_process_poll_pkts(struct octeon_device *oct, ...@@ -804,8 +803,7 @@ octeon_droq_process_poll_pkts(struct octeon_device *oct,
while (total_pkts_processed < budget) { while (total_pkts_processed < budget) {
octeon_droq_check_hw_for_pkts(droq); octeon_droq_check_hw_for_pkts(droq);
pkts_available = pkts_available = min((budget - total_pkts_processed),
CVM_MIN((budget - total_pkts_processed),
(u32)(atomic_read(&droq->pkts_pending))); (u32)(atomic_read(&droq->pkts_pending)));
if (pkts_available == 0) if (pkts_available == 0)
...@@ -988,7 +986,8 @@ int octeon_create_droq(struct octeon_device *oct, ...@@ -988,7 +986,8 @@ int octeon_create_droq(struct octeon_device *oct,
if (!droq) if (!droq)
droq = vmalloc(sizeof(*droq)); droq = vmalloc(sizeof(*droq));
if (!droq) if (!droq)
goto create_droq_fail; return -1;
memset(droq, 0, sizeof(struct octeon_droq)); memset(droq, 0, sizeof(struct octeon_droq));
/*Disable the pkt o/p for this Q */ /*Disable the pkt o/p for this Q */
...@@ -996,7 +995,11 @@ int octeon_create_droq(struct octeon_device *oct, ...@@ -996,7 +995,11 @@ int octeon_create_droq(struct octeon_device *oct,
oct->droq[q_no] = droq; oct->droq[q_no] = droq;
/* Initialize the Droq */ /* Initialize the Droq */
octeon_init_droq(oct, q_no, num_descs, desc_size, app_ctx); if (octeon_init_droq(oct, q_no, num_descs, desc_size, app_ctx)) {
vfree(oct->droq[q_no]);
oct->droq[q_no] = NULL;
return -1;
}
oct->num_oqs++; oct->num_oqs++;
...@@ -1009,8 +1012,4 @@ int octeon_create_droq(struct octeon_device *oct, ...@@ -1009,8 +1012,4 @@ int octeon_create_droq(struct octeon_device *oct,
* the same time. * the same time.
*/ */
return 0; return 0;
create_droq_fail:
octeon_delete_droq(oct, q_no);
return -ENOMEM;
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
...@@ -13,13 +13,8 @@ ...@@ -13,13 +13,8 @@
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more details.
* details. ***********************************************************************/
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/
/*! \file octeon_droq.h /*! \file octeon_droq.h
* \brief Implementation of Octeon Output queues. "Output" is with * \brief Implementation of Octeon Output queues. "Output" is with
* respect to the Octeon device on the NIC. From this driver's point of * respect to the Octeon device on the NIC. From this driver's point of
...@@ -81,7 +76,7 @@ struct octeon_skb_page_info { ...@@ -81,7 +76,7 @@ struct octeon_skb_page_info {
* the Octeon device. Since the descriptor ring keeps physical (bus) * the Octeon device. Since the descriptor ring keeps physical (bus)
* addresses, this field is required for the driver to keep track of * addresses, this field is required for the driver to keep track of
* the virtual address pointers. * the virtual address pointers.
*/ */
struct octeon_recv_buffer { struct octeon_recv_buffer {
/** Packet buffer, including metadata. */ /** Packet buffer, including metadata. */
void *buffer; void *buffer;
...@@ -121,7 +116,6 @@ struct oct_droq_stats { ...@@ -121,7 +116,6 @@ struct oct_droq_stats {
/** Num of Packets dropped due to receive path failures. */ /** Num of Packets dropped due to receive path failures. */
u64 rx_dropped; u64 rx_dropped;
/** Num of vxlan packets received; */
u64 rx_vxlan; u64 rx_vxlan;
/** Num of failures of recv_buffer_alloc() */ /** Num of failures of recv_buffer_alloc() */
...@@ -359,7 +353,7 @@ struct octeon_droq { ...@@ -359,7 +353,7 @@ struct octeon_droq {
* @param q_no - droq no. ranges from 0 - 3. * @param q_no - droq no. ranges from 0 - 3.
* @param app_ctx - pointer to application context * @param app_ctx - pointer to application context
* @return Success: 0 Failure: 1 * @return Success: 0 Failure: 1
*/ */
int octeon_init_droq(struct octeon_device *oct_dev, int octeon_init_droq(struct octeon_device *oct_dev,
u32 q_no, u32 q_no,
u32 num_descs, u32 num_descs,
...@@ -372,7 +366,7 @@ int octeon_init_droq(struct octeon_device *oct_dev, ...@@ -372,7 +366,7 @@ int octeon_init_droq(struct octeon_device *oct_dev,
* @param oct_dev - pointer to the octeon device structure * @param oct_dev - pointer to the octeon device structure
* @param q_no - droq no. ranges from 0 - 3. * @param q_no - droq no. ranges from 0 - 3.
* @return: Success: 0 Failure: 1 * @return: Success: 0 Failure: 1
*/ */
int octeon_delete_droq(struct octeon_device *oct_dev, u32 q_no); int octeon_delete_droq(struct octeon_device *oct_dev, u32 q_no);
/** Register a change in droq operations. The ops field has a pointer to a /** Register a change in droq operations. The ops field has a pointer to a
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
...@@ -13,13 +13,8 @@ ...@@ -13,13 +13,8 @@
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more details.
* details. ***********************************************************************/
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/
/*! \file octeon_iq.h /*! \file octeon_iq.h
* \brief Host Driver: Implementation of Octeon input queues. "Input" is * \brief Host Driver: Implementation of Octeon input queues. "Input" is
* with respect to the Octeon device on the NIC. From this driver's * with respect to the Octeon device on the NIC. From this driver's
...@@ -69,7 +64,6 @@ struct oct_iq_stats { ...@@ -69,7 +64,6 @@ struct oct_iq_stats {
u64 tx_vxlan; /* tunnel */ u64 tx_vxlan; /* tunnel */
u64 tx_dmamap_fail; u64 tx_dmamap_fail;
u64 tx_restart; u64 tx_restart;
/*u64 tx_timeout_count;*/
}; };
#define OCT_IQ_STATS_SIZE (sizeof(struct oct_iq_stats)) #define OCT_IQ_STATS_SIZE (sizeof(struct oct_iq_stats))
...@@ -78,7 +72,7 @@ struct oct_iq_stats { ...@@ -78,7 +72,7 @@ struct oct_iq_stats {
* The input queue is used to post raw (instruction) mode data or packet * The input queue is used to post raw (instruction) mode data or packet
* data to Octeon device from the host. Each input queue (upto 4) for * data to Octeon device from the host. Each input queue (upto 4) for
* a Octeon device has one such structure to represent it. * a Octeon device has one such structure to represent it.
*/ */
struct octeon_instr_queue { struct octeon_instr_queue {
struct octeon_device *oct_dev; struct octeon_device *oct_dev;
...@@ -309,6 +303,9 @@ struct octeon_sc_buffer_pool { ...@@ -309,6 +303,9 @@ struct octeon_sc_buffer_pool {
atomic_t alloc_buf_count; atomic_t alloc_buf_count;
}; };
#define INCR_INSTRQUEUE_PKT_COUNT(octeon_dev_ptr, iq_no, field, count) \
(((octeon_dev_ptr)->instr_queue[iq_no]->stats.field) += count)
int octeon_setup_sc_buffer_pool(struct octeon_device *oct); int octeon_setup_sc_buffer_pool(struct octeon_device *oct);
int octeon_free_sc_buffer_pool(struct octeon_device *oct); int octeon_free_sc_buffer_pool(struct octeon_device *oct);
struct octeon_soft_command * struct octeon_soft_command *
......
/**********************************************************************
* Author: Cavium, Inc.
*
* Contact: support@cavium.com
* Please include "LiquidIO" in the subject.
*
* Copyright (c) 2003-2016 Cavium, Inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as
* published by the Free Software Foundation.
*
* This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more details.
***********************************************************************/
#include <linux/pci.h>
#include <linux/netdevice.h>
#include "liquidio_common.h"
#include "octeon_droq.h"
#include "octeon_iq.h"
#include "response_manager.h"
#include "octeon_device.h"
#include "octeon_main.h"
#include "octeon_mailbox.h"
/**
* octeon_mbox_read:
* @oct: Pointer mailbox
*
* Reads the 8-bytes of data from the mbox register
* Writes back the acknowldgement inidcating completion of read
*/
int octeon_mbox_read(struct octeon_mbox *mbox)
{
union octeon_mbox_message msg;
int ret = 0;
spin_lock(&mbox->lock);
msg.u64 = readq(mbox->mbox_read_reg);
if ((msg.u64 == OCTEON_PFVFACK) || (msg.u64 == OCTEON_PFVFSIG)) {
spin_unlock(&mbox->lock);
return 0;
}
if (mbox->state & OCTEON_MBOX_STATE_REQUEST_RECEIVING) {
mbox->mbox_req.data[mbox->mbox_req.recv_len - 1] = msg.u64;
mbox->mbox_req.recv_len++;
} else {
if (mbox->state & OCTEON_MBOX_STATE_RESPONSE_RECEIVING) {
mbox->mbox_resp.data[mbox->mbox_resp.recv_len - 1] =
msg.u64;
mbox->mbox_resp.recv_len++;
} else {
if ((mbox->state & OCTEON_MBOX_STATE_IDLE) &&
(msg.s.type == OCTEON_MBOX_REQUEST)) {
mbox->state &= ~OCTEON_MBOX_STATE_IDLE;
mbox->state |=
OCTEON_MBOX_STATE_REQUEST_RECEIVING;
mbox->mbox_req.msg.u64 = msg.u64;
mbox->mbox_req.q_no = mbox->q_no;
mbox->mbox_req.recv_len = 1;
} else {
if ((mbox->state &
OCTEON_MBOX_STATE_RESPONSE_PENDING) &&
(msg.s.type == OCTEON_MBOX_RESPONSE)) {
mbox->state &=
~OCTEON_MBOX_STATE_RESPONSE_PENDING;
mbox->state |=
OCTEON_MBOX_STATE_RESPONSE_RECEIVING
;
mbox->mbox_resp.msg.u64 = msg.u64;
mbox->mbox_resp.q_no = mbox->q_no;
mbox->mbox_resp.recv_len = 1;
} else {
writeq(OCTEON_PFVFERR,
mbox->mbox_read_reg);
mbox->state |= OCTEON_MBOX_STATE_ERROR;
spin_unlock(&mbox->lock);
return 1;
}
}
}
}
if (mbox->state & OCTEON_MBOX_STATE_REQUEST_RECEIVING) {
if (mbox->mbox_req.recv_len < msg.s.len) {
ret = 0;
} else {
mbox->state &= ~OCTEON_MBOX_STATE_REQUEST_RECEIVING;
mbox->state |= OCTEON_MBOX_STATE_REQUEST_RECEIVED;
ret = 1;
}
} else {
if (mbox->state & OCTEON_MBOX_STATE_RESPONSE_RECEIVING) {
if (mbox->mbox_resp.recv_len < msg.s.len) {
ret = 0;
} else {
mbox->state &=
~OCTEON_MBOX_STATE_RESPONSE_RECEIVING;
mbox->state |=
OCTEON_MBOX_STATE_RESPONSE_RECEIVED;
ret = 1;
}
} else {
WARN_ON(1);
}
}
writeq(OCTEON_PFVFACK, mbox->mbox_read_reg);
spin_unlock(&mbox->lock);
return ret;
}
/**
* octeon_mbox_write:
* @oct: Pointer Octeon Device
* @mbox_cmd: Cmd to send to mailbox.
*
* Populates the queue specific mbox structure
* with cmd information.
* Write the cmd to mbox register
*/
int octeon_mbox_write(struct octeon_device *oct,
struct octeon_mbox_cmd *mbox_cmd)
{
struct octeon_mbox *mbox = oct->mbox[mbox_cmd->q_no];
u32 count, i, ret = OCTEON_MBOX_STATUS_SUCCESS;
unsigned long flags;
spin_lock_irqsave(&mbox->lock, flags);
if ((mbox_cmd->msg.s.type == OCTEON_MBOX_RESPONSE) &&
!(mbox->state & OCTEON_MBOX_STATE_REQUEST_RECEIVED)) {
spin_unlock_irqrestore(&mbox->lock, flags);
return OCTEON_MBOX_STATUS_FAILED;
}
if ((mbox_cmd->msg.s.type == OCTEON_MBOX_REQUEST) &&
!(mbox->state & OCTEON_MBOX_STATE_IDLE)) {
spin_unlock_irqrestore(&mbox->lock, flags);
return OCTEON_MBOX_STATUS_BUSY;
}
if (mbox_cmd->msg.s.type == OCTEON_MBOX_REQUEST) {
memcpy(&mbox->mbox_resp, mbox_cmd,
sizeof(struct octeon_mbox_cmd));
mbox->state = OCTEON_MBOX_STATE_RESPONSE_PENDING;
}
spin_unlock_irqrestore(&mbox->lock, flags);
count = 0;
while (readq(mbox->mbox_write_reg) != OCTEON_PFVFSIG) {
schedule_timeout_uninterruptible(LIO_MBOX_WRITE_WAIT_TIME);
if (count++ == LIO_MBOX_WRITE_WAIT_CNT) {
ret = OCTEON_MBOX_STATUS_FAILED;
break;
}
}
if (ret == OCTEON_MBOX_STATUS_SUCCESS) {
writeq(mbox_cmd->msg.u64, mbox->mbox_write_reg);
for (i = 0; i < (u32)(mbox_cmd->msg.s.len - 1); i++) {
count = 0;
while (readq(mbox->mbox_write_reg) !=
OCTEON_PFVFACK) {
schedule_timeout_uninterruptible(10);
if (count++ == LIO_MBOX_WRITE_WAIT_CNT) {
ret = OCTEON_MBOX_STATUS_FAILED;
break;
}
}
writeq(mbox_cmd->data[i], mbox->mbox_write_reg);
}
}
spin_lock_irqsave(&mbox->lock, flags);
if (mbox_cmd->msg.s.type == OCTEON_MBOX_RESPONSE) {
mbox->state = OCTEON_MBOX_STATE_IDLE;
writeq(OCTEON_PFVFSIG, mbox->mbox_read_reg);
} else {
if ((!mbox_cmd->msg.s.resp_needed) ||
(ret == OCTEON_MBOX_STATUS_FAILED)) {
mbox->state &= ~OCTEON_MBOX_STATE_RESPONSE_PENDING;
if (!(mbox->state &
(OCTEON_MBOX_STATE_REQUEST_RECEIVING |
OCTEON_MBOX_STATE_REQUEST_RECEIVED)))
mbox->state = OCTEON_MBOX_STATE_IDLE;
}
}
spin_unlock_irqrestore(&mbox->lock, flags);
return ret;
}
/**
* octeon_mbox_process_cmd:
* @mbox: Pointer mailbox
* @mbox_cmd: Pointer to command received
*
* Process the cmd received in mbox
*/
static int octeon_mbox_process_cmd(struct octeon_mbox *mbox,
struct octeon_mbox_cmd *mbox_cmd)
{
struct octeon_device *oct = mbox->oct_dev;
switch (mbox_cmd->msg.s.cmd) {
case OCTEON_VF_ACTIVE:
dev_dbg(&oct->pci_dev->dev, "got vfactive sending data back\n");
mbox_cmd->msg.s.type = OCTEON_MBOX_RESPONSE;
mbox_cmd->msg.s.resp_needed = 1;
mbox_cmd->msg.s.len = 2;
mbox_cmd->data[0] = 0; /* VF version is in mbox_cmd->data[0] */
((struct lio_version *)&mbox_cmd->data[0])->major =
LIQUIDIO_BASE_MAJOR_VERSION;
((struct lio_version *)&mbox_cmd->data[0])->minor =
LIQUIDIO_BASE_MINOR_VERSION;
((struct lio_version *)&mbox_cmd->data[0])->micro =
LIQUIDIO_BASE_MICRO_VERSION;
memcpy(mbox_cmd->msg.s.params, (uint8_t *)&oct->pfvf_hsword, 6);
/* Sending core cofig info to the corresponding active VF.*/
octeon_mbox_write(oct, mbox_cmd);
break;
case OCTEON_VF_FLR_REQUEST:
dev_info(&oct->pci_dev->dev,
"got a request for FLR from VF that owns DPI ring %u\n",
mbox->q_no);
pcie_capability_set_word(
oct->sriov_info.dpiring_to_vfpcidev_lut[mbox->q_no],
PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR);
break;
case OCTEON_PF_CHANGED_VF_MACADDR:
if (OCTEON_CN23XX_VF(oct))
octeon_pf_changed_vf_macaddr(oct,
mbox_cmd->msg.s.params);
break;
default:
break;
}
return 0;
}
/**
*octeon_mbox_process_message:
*
* Process the received mbox message.
*/
int octeon_mbox_process_message(struct octeon_mbox *mbox)
{
struct octeon_mbox_cmd mbox_cmd;
unsigned long flags;
spin_lock_irqsave(&mbox->lock, flags);
if (mbox->state & OCTEON_MBOX_STATE_ERROR) {
if (mbox->state & (OCTEON_MBOX_STATE_RESPONSE_PENDING |
OCTEON_MBOX_STATE_RESPONSE_RECEIVING)) {
memcpy(&mbox_cmd, &mbox->mbox_resp,
sizeof(struct octeon_mbox_cmd));
mbox->state = OCTEON_MBOX_STATE_IDLE;
writeq(OCTEON_PFVFSIG, mbox->mbox_read_reg);
spin_unlock_irqrestore(&mbox->lock, flags);
mbox_cmd.recv_status = 1;
if (mbox_cmd.fn)
mbox_cmd.fn(mbox->oct_dev, &mbox_cmd,
mbox_cmd.fn_arg);
return 0;
}
mbox->state = OCTEON_MBOX_STATE_IDLE;
writeq(OCTEON_PFVFSIG, mbox->mbox_read_reg);
spin_unlock_irqrestore(&mbox->lock, flags);
return 0;
}
if (mbox->state & OCTEON_MBOX_STATE_RESPONSE_RECEIVED) {
memcpy(&mbox_cmd, &mbox->mbox_resp,
sizeof(struct octeon_mbox_cmd));
mbox->state = OCTEON_MBOX_STATE_IDLE;
writeq(OCTEON_PFVFSIG, mbox->mbox_read_reg);
spin_unlock_irqrestore(&mbox->lock, flags);
mbox_cmd.recv_status = 0;
if (mbox_cmd.fn)
mbox_cmd.fn(mbox->oct_dev, &mbox_cmd, mbox_cmd.fn_arg);
return 0;
}
if (mbox->state & OCTEON_MBOX_STATE_REQUEST_RECEIVED) {
memcpy(&mbox_cmd, &mbox->mbox_req,
sizeof(struct octeon_mbox_cmd));
if (!mbox_cmd.msg.s.resp_needed) {
mbox->state &= ~OCTEON_MBOX_STATE_REQUEST_RECEIVED;
if (!(mbox->state &&
OCTEON_MBOX_STATE_RESPONSE_PENDING))
mbox->state = OCTEON_MBOX_STATE_IDLE;
writeq(OCTEON_PFVFSIG, mbox->mbox_read_reg);
}
spin_unlock_irqrestore(&mbox->lock, flags);
octeon_mbox_process_cmd(mbox, &mbox_cmd);
return 0;
}
WARN_ON(1);
return 0;
}
/**********************************************************************
* Author: Cavium, Inc.
*
* Contact: support@cavium.com
* Please include "LiquidIO" in the subject.
*
* Copyright (c) 2003-2016 Cavium, Inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as
* published by the Free Software Foundation.
*
* This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more details.
***********************************************************************/
#ifndef __MAILBOX_H__
#define __MAILBOX_H__
/* Macros for Mail Box Communication */
#define OCTEON_MBOX_DATA_MAX 32
#define OCTEON_VF_ACTIVE 0x1
#define OCTEON_VF_FLR_REQUEST 0x2
#define OCTEON_PF_CHANGED_VF_MACADDR 0x4
/*Macro for Read acknowldgement*/
#define OCTEON_PFVFACK 0xffffffffffffffff
#define OCTEON_PFVFSIG 0x1122334455667788
#define OCTEON_PFVFERR 0xDEADDEADDEADDEAD
#define LIO_MBOX_WRITE_WAIT_CNT 1000
#define LIO_MBOX_WRITE_WAIT_TIME 10
enum octeon_mbox_cmd_status {
OCTEON_MBOX_STATUS_SUCCESS = 0,
OCTEON_MBOX_STATUS_FAILED = 1,
OCTEON_MBOX_STATUS_BUSY = 2
};
enum octeon_mbox_message_type {
OCTEON_MBOX_REQUEST = 0,
OCTEON_MBOX_RESPONSE = 1
};
union octeon_mbox_message {
u64 u64;
struct {
u16 type : 1;
u16 resp_needed : 1;
u16 cmd : 6;
u16 len : 8;
u8 params[6];
} s;
};
typedef void (*octeon_mbox_callback_t)(void *, void *, void *);
struct octeon_mbox_cmd {
union octeon_mbox_message msg;
u64 data[OCTEON_MBOX_DATA_MAX];
u32 q_no;
u32 recv_len;
u32 recv_status;
octeon_mbox_callback_t fn;
void *fn_arg;
};
enum octeon_mbox_state {
OCTEON_MBOX_STATE_IDLE = 1,
OCTEON_MBOX_STATE_REQUEST_RECEIVING = 2,
OCTEON_MBOX_STATE_REQUEST_RECEIVED = 4,
OCTEON_MBOX_STATE_RESPONSE_PENDING = 8,
OCTEON_MBOX_STATE_RESPONSE_RECEIVING = 16,
OCTEON_MBOX_STATE_RESPONSE_RECEIVED = 16,
OCTEON_MBOX_STATE_ERROR = 32
};
struct octeon_mbox {
/** A spinlock to protect access to this q_mbox. */
spinlock_t lock;
struct octeon_device *oct_dev;
u32 q_no;
enum octeon_mbox_state state;
struct cavium_wk mbox_poll_wk;
/** SLI_MAC_PF_MBOX_INT for PF, SLI_PKT_MBOX_INT for VF. */
void *mbox_int_reg;
/** SLI_PKT_PF_VF_MBOX_SIG(0) for PF, SLI_PKT_PF_VF_MBOX_SIG(1) for VF.
*/
void *mbox_write_reg;
/** SLI_PKT_PF_VF_MBOX_SIG(1) for PF, SLI_PKT_PF_VF_MBOX_SIG(0) for VF.
*/
void *mbox_read_reg;
struct octeon_mbox_cmd mbox_req;
struct octeon_mbox_cmd mbox_resp;
};
int octeon_mbox_read(struct octeon_mbox *mbox);
int octeon_mbox_write(struct octeon_device *oct,
struct octeon_mbox_cmd *mbox_cmd);
int octeon_mbox_process_message(struct octeon_mbox *mbox);
#endif
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
...@@ -13,13 +13,8 @@ ...@@ -13,13 +13,8 @@
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more details.
* details. ***********************************************************************/
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/
/*! \file octeon_main.h /*! \file octeon_main.h
* \brief Host Driver: This file is included by all host driver source files * \brief Host Driver: This file is included by all host driver source files
* to include common definitions. * to include common definitions.
...@@ -66,7 +61,7 @@ void octeon_update_tx_completion_counters(void *buf, int reqtype, ...@@ -66,7 +61,7 @@ void octeon_update_tx_completion_counters(void *buf, int reqtype,
unsigned int *bytes_compl); unsigned int *bytes_compl);
void octeon_report_tx_completion_to_bql(void *txq, unsigned int pkts_compl, void octeon_report_tx_completion_to_bql(void *txq, unsigned int pkts_compl,
unsigned int bytes_compl); unsigned int bytes_compl);
void octeon_pf_changed_vf_macaddr(struct octeon_device *oct, u8 *mac);
/** Swap 8B blocks */ /** Swap 8B blocks */
static inline void octeon_swap_8B_data(u64 *data, u32 blocks) static inline void octeon_swap_8B_data(u64 *data, u32 blocks)
{ {
...@@ -116,7 +111,7 @@ static inline int octeon_map_pci_barx(struct octeon_device *oct, ...@@ -116,7 +111,7 @@ static inline int octeon_map_pci_barx(struct octeon_device *oct,
mapped_len = oct->mmio[baridx].len; mapped_len = oct->mmio[baridx].len;
if (!mapped_len) if (!mapped_len)
return 1; goto err_release_region;
if (max_map_len && (mapped_len > max_map_len)) if (max_map_len && (mapped_len > max_map_len))
mapped_len = max_map_len; mapped_len = max_map_len;
...@@ -132,11 +127,15 @@ static inline int octeon_map_pci_barx(struct octeon_device *oct, ...@@ -132,11 +127,15 @@ static inline int octeon_map_pci_barx(struct octeon_device *oct,
if (!oct->mmio[baridx].hw_addr) { if (!oct->mmio[baridx].hw_addr) {
dev_err(&oct->pci_dev->dev, "error ioremap for bar %d\n", dev_err(&oct->pci_dev->dev, "error ioremap for bar %d\n",
baridx); baridx);
return 1; goto err_release_region;
} }
oct->mmio[baridx].done = 1; oct->mmio[baridx].done = 1;
return 0; return 0;
err_release_region:
pci_release_region(oct->pci_dev, baridx * 2);
return 1;
} }
static inline void * static inline void *
...@@ -203,24 +202,6 @@ sleep_cond(wait_queue_head_t *wait_queue, int *condition) ...@@ -203,24 +202,6 @@ sleep_cond(wait_queue_head_t *wait_queue, int *condition)
return errno; return errno;
} }
static inline void
sleep_atomic_cond(wait_queue_head_t *waitq, atomic_t *pcond)
{
wait_queue_t we;
init_waitqueue_entry(&we, current);
add_wait_queue(waitq, &we);
while (!atomic_read(pcond)) {
set_current_state(TASK_INTERRUPTIBLE);
if (signal_pending(current))
goto out;
schedule();
}
out:
set_current_state(TASK_RUNNING);
remove_wait_queue(waitq, &we);
}
/* Gives up the CPU for a timeout period. /* Gives up the CPU for a timeout period.
* Check that the condition is not true before we go to sleep for a * Check that the condition is not true before we go to sleep for a
* timeout period. * timeout period.
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more
* details. * details.
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/ **********************************************************************/
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include "liquidio_common.h" #include "liquidio_common.h"
...@@ -39,7 +36,7 @@ octeon_toggle_bar1_swapmode(struct octeon_device *oct, u32 idx) ...@@ -39,7 +36,7 @@ octeon_toggle_bar1_swapmode(struct octeon_device *oct, u32 idx)
oct->fn_list.bar1_idx_write(oct, idx, mask); oct->fn_list.bar1_idx_write(oct, idx, mask);
} }
#else #else
#define octeon_toggle_bar1_swapmode(oct, idx) (oct = oct) #define octeon_toggle_bar1_swapmode(oct, idx)
#endif #endif
static void static void
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more
* details. * details.
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/ **********************************************************************/
/*! \file octeon_mem_ops.h /*! \file octeon_mem_ops.h
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more
* details. * details.
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/ **********************************************************************/
/*! \file octeon_network.h /*! \file octeon_network.h
...@@ -131,7 +128,7 @@ struct lio { ...@@ -131,7 +128,7 @@ struct lio {
#define LIO_SIZE (sizeof(struct lio)) #define LIO_SIZE (sizeof(struct lio))
#define GET_LIO(netdev) ((struct lio *)netdev_priv(netdev)) #define GET_LIO(netdev) ((struct lio *)netdev_priv(netdev))
#define CIU3_WDOG(c) (0x1010000020000ULL + (c << 3)) #define CIU3_WDOG(c) (0x1010000020000ULL + ((c) << 3))
#define CIU3_WDOG_MASK 12ULL #define CIU3_WDOG_MASK 12ULL
#define LIO_MONITOR_WDOG_EXPIRE 1 #define LIO_MONITOR_WDOG_EXPIRE 1
#define LIO_MONITOR_CORE_STUCK_MSGD 2 #define LIO_MONITOR_CORE_STUCK_MSGD 2
...@@ -342,9 +339,9 @@ static inline void tx_buffer_free(void *buffer) ...@@ -342,9 +339,9 @@ static inline void tx_buffer_free(void *buffer)
} }
#define lio_dma_alloc(oct, size, dma_addr) \ #define lio_dma_alloc(oct, size, dma_addr) \
dma_alloc_coherent(&oct->pci_dev->dev, size, dma_addr, GFP_KERNEL) dma_alloc_coherent(&(oct)->pci_dev->dev, size, dma_addr, GFP_KERNEL)
#define lio_dma_free(oct, size, virt_addr, dma_addr) \ #define lio_dma_free(oct, size, virt_addr, dma_addr) \
dma_free_coherent(&oct->pci_dev->dev, size, virt_addr, dma_addr) dma_free_coherent(&(oct)->pci_dev->dev, size, virt_addr, dma_addr)
static inline static inline
void *get_rbd(struct sk_buff *skb) void *get_rbd(struct sk_buff *skb)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more
* details. * details.
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/ **********************************************************************/
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more
* details. * details.
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/ **********************************************************************/
/*! \file octeon_nic.h /*! \file octeon_nic.h
...@@ -67,7 +64,7 @@ struct octnic_ctrl_pkt { ...@@ -67,7 +64,7 @@ struct octnic_ctrl_pkt {
octnic_ctrl_pkt_cb_fn_t cb_fn; octnic_ctrl_pkt_cb_fn_t cb_fn;
}; };
#define MAX_UDD_SIZE(nctrl) (sizeof(nctrl->udd)) #define MAX_UDD_SIZE(nctrl) (sizeof((nctrl)->udd))
/** Structure of data information passed by the NIC module to the OSI /** Structure of data information passed by the NIC module to the OSI
* layer when forwarding data to Octeon device software. * layer when forwarding data to Octeon device software.
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more
* details. * details.
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/ **********************************************************************/
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
...@@ -32,9 +29,6 @@ ...@@ -32,9 +29,6 @@
#include "cn66xx_device.h" #include "cn66xx_device.h"
#include "cn23xx_pf_device.h" #include "cn23xx_pf_device.h"
#define INCR_INSTRQUEUE_PKT_COUNT(octeon_dev_ptr, iq_no, field, count) \
(octeon_dev_ptr->instr_queue[iq_no]->stats.field += count)
struct iq_post_status { struct iq_post_status {
int status; int status;
int index; int index;
...@@ -71,9 +65,9 @@ int octeon_init_instr_queue(struct octeon_device *oct, ...@@ -71,9 +65,9 @@ int octeon_init_instr_queue(struct octeon_device *oct,
int numa_node = cpu_to_node(iq_no % num_online_cpus()); int numa_node = cpu_to_node(iq_no % num_online_cpus());
if (OCTEON_CN6XXX(oct)) if (OCTEON_CN6XXX(oct))
conf = &(CFG_GET_IQ_CFG(CHIP_FIELD(oct, cn6xxx, conf))); conf = &(CFG_GET_IQ_CFG(CHIP_CONF(oct, cn6xxx)));
else if (OCTEON_CN23XX_PF(oct)) else if (OCTEON_CN23XX_PF(oct))
conf = &(CFG_GET_IQ_CFG(CHIP_FIELD(oct, cn23xx_pf, conf))); conf = &(CFG_GET_IQ_CFG(CHIP_CONF(oct, cn23xx_pf)));
if (!conf) { if (!conf) {
dev_err(&oct->pci_dev->dev, "Unsupported Chip %x\n", dev_err(&oct->pci_dev->dev, "Unsupported Chip %x\n",
oct->chip_id); oct->chip_id);
...@@ -145,7 +139,7 @@ int octeon_init_instr_queue(struct octeon_device *oct, ...@@ -145,7 +139,7 @@ int octeon_init_instr_queue(struct octeon_device *oct,
spin_lock_init(&iq->iq_flush_running_lock); spin_lock_init(&iq->iq_flush_running_lock);
oct->io_qmask.iq |= (1ULL << iq_no); oct->io_qmask.iq |= BIT_ULL(iq_no);
/* Set the 32B/64B mode for each input queue */ /* Set the 32B/64B mode for each input queue */
oct->io_qmask.iq64B |= ((conf->instr_type == 64) << iq_no); oct->io_qmask.iq64B |= ((conf->instr_type == 64) << iq_no);
...@@ -157,6 +151,8 @@ int octeon_init_instr_queue(struct octeon_device *oct, ...@@ -157,6 +151,8 @@ int octeon_init_instr_queue(struct octeon_device *oct,
WQ_MEM_RECLAIM, WQ_MEM_RECLAIM,
0); 0);
if (!oct->check_db_wq[iq_no].wq) { if (!oct->check_db_wq[iq_no].wq) {
vfree(iq->request_list);
iq->request_list = NULL;
lio_dma_free(oct, q_size, iq->base_addr, iq->base_addr_dma); lio_dma_free(oct, q_size, iq->base_addr, iq->base_addr_dma);
dev_err(&oct->pci_dev->dev, "check db wq create failed for iq %d\n", dev_err(&oct->pci_dev->dev, "check db wq create failed for iq %d\n",
iq_no); iq_no);
...@@ -183,10 +179,10 @@ int octeon_delete_instr_queue(struct octeon_device *oct, u32 iq_no) ...@@ -183,10 +179,10 @@ int octeon_delete_instr_queue(struct octeon_device *oct, u32 iq_no)
if (OCTEON_CN6XXX(oct)) if (OCTEON_CN6XXX(oct))
desc_size = desc_size =
CFG_GET_IQ_INSTR_TYPE(CHIP_FIELD(oct, cn6xxx, conf)); CFG_GET_IQ_INSTR_TYPE(CHIP_CONF(oct, cn6xxx));
else if (OCTEON_CN23XX_PF(oct)) else if (OCTEON_CN23XX_PF(oct))
desc_size = desc_size =
CFG_GET_IQ_INSTR_TYPE(CHIP_FIELD(oct, cn23xx_pf, conf)); CFG_GET_IQ_INSTR_TYPE(CHIP_CONF(oct, cn23xx_pf));
vfree(iq->request_list); vfree(iq->request_list);
...@@ -250,9 +246,8 @@ int lio_wait_for_instr_fetch(struct octeon_device *oct) ...@@ -250,9 +246,8 @@ int lio_wait_for_instr_fetch(struct octeon_device *oct)
do { do {
instr_cnt = 0; instr_cnt = 0;
/*for (i = 0; i < oct->num_iqs; i++) {*/
for (i = 0; i < MAX_OCTEON_INSTR_QUEUES(oct); i++) { for (i = 0; i < MAX_OCTEON_INSTR_QUEUES(oct); i++) {
if (!(oct->io_qmask.iq & (1ULL << i))) if (!(oct->io_qmask.iq & BIT_ULL(i)))
continue; continue;
pending = pending =
atomic_read(&oct-> atomic_read(&oct->
...@@ -319,7 +314,8 @@ __post_command2(struct octeon_instr_queue *iq, u8 *cmd) ...@@ -319,7 +314,8 @@ __post_command2(struct octeon_instr_queue *iq, u8 *cmd)
/* "index" is returned, host_write_index is modified. */ /* "index" is returned, host_write_index is modified. */
st.index = iq->host_write_index; st.index = iq->host_write_index;
INCR_INDEX_BY1(iq->host_write_index, iq->max_count); iq->host_write_index = incr_index(iq->host_write_index, 1,
iq->max_count);
iq->fill_cnt++; iq->fill_cnt++;
/* Flush the command into memory. We need to be sure the data is in /* Flush the command into memory. We need to be sure the data is in
...@@ -434,7 +430,7 @@ lio_process_iq_request_list(struct octeon_device *oct, ...@@ -434,7 +430,7 @@ lio_process_iq_request_list(struct octeon_device *oct,
skip_this: skip_this:
inst_count++; inst_count++;
INCR_INDEX_BY1(old, iq->max_count); old = incr_index(old, 1, iq->max_count);
if ((napi_budget) && (inst_count >= napi_budget)) if ((napi_budget) && (inst_count >= napi_budget))
break; break;
...@@ -577,8 +573,6 @@ octeon_send_command(struct octeon_device *oct, u32 iq_no, ...@@ -577,8 +573,6 @@ octeon_send_command(struct octeon_device *oct, u32 iq_no,
/* This is only done here to expedite packets being flushed /* This is only done here to expedite packets being flushed
* for cases where there are no IQ completion interrupts. * for cases where there are no IQ completion interrupts.
*/ */
/*if (iq->do_auto_flush)*/
/* octeon_flush_iq(oct, iq, 2, 0);*/
return st.status; return st.status;
} }
...@@ -749,8 +743,10 @@ int octeon_setup_sc_buffer_pool(struct octeon_device *oct) ...@@ -749,8 +743,10 @@ int octeon_setup_sc_buffer_pool(struct octeon_device *oct)
lio_dma_alloc(oct, lio_dma_alloc(oct,
SOFT_COMMAND_BUFFER_SIZE, SOFT_COMMAND_BUFFER_SIZE,
(dma_addr_t *)&dma_addr); (dma_addr_t *)&dma_addr);
if (!sc) if (!sc) {
octeon_free_sc_buffer_pool(oct);
return 1; return 1;
}
sc->dma_addr = dma_addr; sc->dma_addr = dma_addr;
sc->size = SOFT_COMMAND_BUFFER_SIZE; sc->size = SOFT_COMMAND_BUFFER_SIZE;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more
* details. * details.
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/ **********************************************************************/
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
...@@ -81,11 +78,7 @@ int lio_process_ordered_list(struct octeon_device *octeon_dev, ...@@ -81,11 +78,7 @@ int lio_process_ordered_list(struct octeon_device *octeon_dev,
spin_lock_bh(&ordered_sc_list->lock); spin_lock_bh(&ordered_sc_list->lock);
if (ordered_sc_list->head.next == &ordered_sc_list->head) { if (ordered_sc_list->head.next == &ordered_sc_list->head) {
/* ordered_sc_list is empty; there is spin_unlock_bh(&ordered_sc_list->lock);
* nothing to process
*/
spin_unlock_bh
(&ordered_sc_list->lock);
return 1; return 1;
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Contact: support@cavium.com * Contact: support@cavium.com
* Please include "LiquidIO" in the subject. * Please include "LiquidIO" in the subject.
* *
* Copyright (c) 2003-2015 Cavium, Inc. * Copyright (c) 2003-2016 Cavium, Inc.
* *
* This file is free software; you can redistribute it and/or modify * This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as * it under the terms of the GNU General Public License, Version 2, as
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more * NONINFRINGEMENT. See the GNU General Public License for more
* details. * details.
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/ **********************************************************************/
/*! \file response_manager.h /*! \file response_manager.h
...@@ -85,7 +82,6 @@ enum { ...@@ -85,7 +82,6 @@ enum {
/** A value of 0x00000000 indicates no error i.e. success */ /** A value of 0x00000000 indicates no error i.e. success */
#define DRIVER_ERROR_NONE 0x00000000 #define DRIVER_ERROR_NONE 0x00000000
/** (Major number: 0x0000; Minor Number: 0x0001) */
#define DRIVER_ERROR_REQ_PENDING 0x00000001 #define DRIVER_ERROR_REQ_PENDING 0x00000001
#define DRIVER_ERROR_REQ_TIMEOUT 0x00000003 #define DRIVER_ERROR_REQ_TIMEOUT 0x00000003
#define DRIVER_ERROR_REQ_EINTR 0x00000004 #define DRIVER_ERROR_REQ_EINTR 0x00000004
......
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