Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH] wireless/p54: Remove duplicated net2280 header
From: Ricardo Ribalda Delgado @ 2014-12-01 10:46 UTC (permalink / raw)
  To: Christian Lamparter, John W. Linville, LKML, linux-wireless,
	netdev, David Miller
  Cc: Ricardo Ribalda Delgado
In-Reply-To: <1416824391-13976-1-git-send-email-ricardo.ribalda@gmail.com>

David Miller has marked the patch as "Awaiting Upstream", which I
think means that it should be merged through the wireless tree.

Any comment from there?

On Mon, Nov 24, 2014 at 11:19 AM, Ricardo Ribalda Delgado
<ricardo.ribalda@gmail.com> wrote:
> The usb gadget driver net2280 has exported a header file with the
> register definition of the net2280 chip.
>
> Remove the custom/duplicated header file in favor of that header file
> in include/linux
>
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
> ---
>  drivers/net/wireless/p54/net2280.h | 451 -------------------------------------
>  drivers/net/wireless/p54/p54usb.h  |  13 +-
>  2 files changed, 12 insertions(+), 452 deletions(-)
>  delete mode 100644 drivers/net/wireless/p54/net2280.h
>
> diff --git a/drivers/net/wireless/p54/net2280.h b/drivers/net/wireless/p54/net2280.h
> deleted file mode 100644
> index aedfaf2..0000000
> --- a/drivers/net/wireless/p54/net2280.h
> +++ /dev/null
> @@ -1,451 +0,0 @@
> -#ifndef NET2280_H
> -#define NET2280_H
> -/*
> - * NetChip 2280 high/full speed USB device controller.
> - * Unlike many such controllers, this one talks PCI.
> - */
> -
> -/*
> - * Copyright (C) 2002 NetChip Technology, Inc. (http://www.netchip.com)
> - * Copyright (C) 2003 David Brownell
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, see <http://www.gnu.org/licenses/>.
> - */
> -
> -/*-------------------------------------------------------------------------*/
> -
> -/* NET2280 MEMORY MAPPED REGISTERS
> - *
> - * The register layout came from the chip documentation, and the bit
> - * number definitions were extracted from chip specification.
> - *
> - * Use the shift operator ('<<') to build bit masks, with readl/writel
> - * to access the registers through PCI.
> - */
> -
> -/* main registers, BAR0 + 0x0000 */
> -struct net2280_regs {
> -       /* offset 0x0000 */
> -       __le32                  devinit;
> -#define LOCAL_CLOCK_FREQUENCY                                  8
> -#define FORCE_PCI_RESET                                                7
> -#define PCI_ID                                                 6
> -#define PCI_ENABLE                                             5
> -#define FIFO_SOFT_RESET                                                4
> -#define CFG_SOFT_RESET                                         3
> -#define PCI_SOFT_RESET                                         2
> -#define USB_SOFT_RESET                                         1
> -#define M8051_RESET                                            0
> -       __le32                  eectl;
> -#define EEPROM_ADDRESS_WIDTH                                   23
> -#define EEPROM_CHIP_SELECT_ACTIVE                              22
> -#define EEPROM_PRESENT                                         21
> -#define EEPROM_VALID                                           20
> -#define EEPROM_BUSY                                            19
> -#define EEPROM_CHIP_SELECT_ENABLE                              18
> -#define EEPROM_BYTE_READ_START                                 17
> -#define EEPROM_BYTE_WRITE_START                                        16
> -#define EEPROM_READ_DATA                                       8
> -#define EEPROM_WRITE_DATA                                      0
> -       __le32                  eeclkfreq;
> -       u32                     _unused0;
> -       /* offset 0x0010 */
> -
> -       __le32                  pciirqenb0;     /* interrupt PCI master ... */
> -#define SETUP_PACKET_INTERRUPT_ENABLE                          7
> -#define ENDPOINT_F_INTERRUPT_ENABLE                            6
> -#define ENDPOINT_E_INTERRUPT_ENABLE                            5
> -#define ENDPOINT_D_INTERRUPT_ENABLE                            4
> -#define ENDPOINT_C_INTERRUPT_ENABLE                            3
> -#define ENDPOINT_B_INTERRUPT_ENABLE                            2
> -#define ENDPOINT_A_INTERRUPT_ENABLE                            1
> -#define ENDPOINT_0_INTERRUPT_ENABLE                            0
> -       __le32                  pciirqenb1;
> -#define PCI_INTERRUPT_ENABLE                                   31
> -#define POWER_STATE_CHANGE_INTERRUPT_ENABLE                    27
> -#define PCI_ARBITER_TIMEOUT_INTERRUPT_ENABLE                   26
> -#define PCI_PARITY_ERROR_INTERRUPT_ENABLE                      25
> -#define PCI_MASTER_ABORT_RECEIVED_INTERRUPT_ENABLE             20
> -#define PCI_TARGET_ABORT_RECEIVED_INTERRUPT_ENABLE             19
> -#define PCI_TARGET_ABORT_ASSERTED_INTERRUPT_ENABLE             18
> -#define PCI_RETRY_ABORT_INTERRUPT_ENABLE                       17
> -#define PCI_MASTER_CYCLE_DONE_INTERRUPT_ENABLE                 16
> -#define GPIO_INTERRUPT_ENABLE                                  13
> -#define DMA_D_INTERRUPT_ENABLE                                 12
> -#define DMA_C_INTERRUPT_ENABLE                                 11
> -#define DMA_B_INTERRUPT_ENABLE                                 10
> -#define DMA_A_INTERRUPT_ENABLE                                 9
> -#define EEPROM_DONE_INTERRUPT_ENABLE                           8
> -#define VBUS_INTERRUPT_ENABLE                                  7
> -#define CONTROL_STATUS_INTERRUPT_ENABLE                                6
> -#define ROOT_PORT_RESET_INTERRUPT_ENABLE                       4
> -#define SUSPEND_REQUEST_INTERRUPT_ENABLE                       3
> -#define SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE                        2
> -#define RESUME_INTERRUPT_ENABLE                                        1
> -#define SOF_INTERRUPT_ENABLE                                   0
> -       __le32                  cpu_irqenb0;    /* ... or onboard 8051 */
> -#define SETUP_PACKET_INTERRUPT_ENABLE                          7
> -#define ENDPOINT_F_INTERRUPT_ENABLE                            6
> -#define ENDPOINT_E_INTERRUPT_ENABLE                            5
> -#define ENDPOINT_D_INTERRUPT_ENABLE                            4
> -#define ENDPOINT_C_INTERRUPT_ENABLE                            3
> -#define ENDPOINT_B_INTERRUPT_ENABLE                            2
> -#define ENDPOINT_A_INTERRUPT_ENABLE                            1
> -#define ENDPOINT_0_INTERRUPT_ENABLE                            0
> -       __le32                  cpu_irqenb1;
> -#define CPU_INTERRUPT_ENABLE                                   31
> -#define POWER_STATE_CHANGE_INTERRUPT_ENABLE                    27
> -#define PCI_ARBITER_TIMEOUT_INTERRUPT_ENABLE                   26
> -#define PCI_PARITY_ERROR_INTERRUPT_ENABLE                      25
> -#define PCI_INTA_INTERRUPT_ENABLE                              24
> -#define PCI_PME_INTERRUPT_ENABLE                               23
> -#define PCI_SERR_INTERRUPT_ENABLE                              22
> -#define PCI_PERR_INTERRUPT_ENABLE                              21
> -#define PCI_MASTER_ABORT_RECEIVED_INTERRUPT_ENABLE             20
> -#define PCI_TARGET_ABORT_RECEIVED_INTERRUPT_ENABLE             19
> -#define PCI_RETRY_ABORT_INTERRUPT_ENABLE                       17
> -#define PCI_MASTER_CYCLE_DONE_INTERRUPT_ENABLE                 16
> -#define GPIO_INTERRUPT_ENABLE                                  13
> -#define DMA_D_INTERRUPT_ENABLE                                 12
> -#define DMA_C_INTERRUPT_ENABLE                                 11
> -#define DMA_B_INTERRUPT_ENABLE                                 10
> -#define DMA_A_INTERRUPT_ENABLE                                 9
> -#define EEPROM_DONE_INTERRUPT_ENABLE                           8
> -#define VBUS_INTERRUPT_ENABLE                                  7
> -#define CONTROL_STATUS_INTERRUPT_ENABLE                                6
> -#define ROOT_PORT_RESET_INTERRUPT_ENABLE                       4
> -#define SUSPEND_REQUEST_INTERRUPT_ENABLE                       3
> -#define SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE                        2
> -#define RESUME_INTERRUPT_ENABLE                                        1
> -#define SOF_INTERRUPT_ENABLE                                   0
> -
> -       /* offset 0x0020 */
> -       u32                     _unused1;
> -       __le32                  usbirqenb1;
> -#define USB_INTERRUPT_ENABLE                                   31
> -#define POWER_STATE_CHANGE_INTERRUPT_ENABLE                    27
> -#define PCI_ARBITER_TIMEOUT_INTERRUPT_ENABLE                   26
> -#define PCI_PARITY_ERROR_INTERRUPT_ENABLE                      25
> -#define PCI_INTA_INTERRUPT_ENABLE                              24
> -#define PCI_PME_INTERRUPT_ENABLE                               23
> -#define PCI_SERR_INTERRUPT_ENABLE                              22
> -#define PCI_PERR_INTERRUPT_ENABLE                              21
> -#define PCI_MASTER_ABORT_RECEIVED_INTERRUPT_ENABLE             20
> -#define PCI_TARGET_ABORT_RECEIVED_INTERRUPT_ENABLE             19
> -#define PCI_RETRY_ABORT_INTERRUPT_ENABLE                       17
> -#define PCI_MASTER_CYCLE_DONE_INTERRUPT_ENABLE                 16
> -#define GPIO_INTERRUPT_ENABLE                                  13
> -#define DMA_D_INTERRUPT_ENABLE                                 12
> -#define DMA_C_INTERRUPT_ENABLE                                 11
> -#define DMA_B_INTERRUPT_ENABLE                                 10
> -#define DMA_A_INTERRUPT_ENABLE                                 9
> -#define EEPROM_DONE_INTERRUPT_ENABLE                           8
> -#define VBUS_INTERRUPT_ENABLE                                  7
> -#define CONTROL_STATUS_INTERRUPT_ENABLE                                6
> -#define ROOT_PORT_RESET_INTERRUPT_ENABLE                       4
> -#define SUSPEND_REQUEST_INTERRUPT_ENABLE                       3
> -#define SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE                        2
> -#define RESUME_INTERRUPT_ENABLE                                        1
> -#define SOF_INTERRUPT_ENABLE                                   0
> -       __le32                  irqstat0;
> -#define INTA_ASSERTED                                          12
> -#define SETUP_PACKET_INTERRUPT                                 7
> -#define ENDPOINT_F_INTERRUPT                                   6
> -#define ENDPOINT_E_INTERRUPT                                   5
> -#define ENDPOINT_D_INTERRUPT                                   4
> -#define ENDPOINT_C_INTERRUPT                                   3
> -#define ENDPOINT_B_INTERRUPT                                   2
> -#define ENDPOINT_A_INTERRUPT                                   1
> -#define ENDPOINT_0_INTERRUPT                                   0
> -       __le32                  irqstat1;
> -#define POWER_STATE_CHANGE_INTERRUPT                           27
> -#define PCI_ARBITER_TIMEOUT_INTERRUPT                          26
> -#define PCI_PARITY_ERROR_INTERRUPT                             25
> -#define PCI_INTA_INTERRUPT                                     24
> -#define PCI_PME_INTERRUPT                                      23
> -#define PCI_SERR_INTERRUPT                                     22
> -#define PCI_PERR_INTERRUPT                                     21
> -#define PCI_MASTER_ABORT_RECEIVED_INTERRUPT                    20
> -#define PCI_TARGET_ABORT_RECEIVED_INTERRUPT                    19
> -#define PCI_RETRY_ABORT_INTERRUPT                              17
> -#define PCI_MASTER_CYCLE_DONE_INTERRUPT                                16
> -#define GPIO_INTERRUPT                                         13
> -#define DMA_D_INTERRUPT                                                12
> -#define DMA_C_INTERRUPT                                                11
> -#define DMA_B_INTERRUPT                                                10
> -#define DMA_A_INTERRUPT                                                9
> -#define EEPROM_DONE_INTERRUPT                                  8
> -#define VBUS_INTERRUPT                                         7
> -#define CONTROL_STATUS_INTERRUPT                               6
> -#define ROOT_PORT_RESET_INTERRUPT                              4
> -#define SUSPEND_REQUEST_INTERRUPT                              3
> -#define SUSPEND_REQUEST_CHANGE_INTERRUPT                       2
> -#define RESUME_INTERRUPT                                       1
> -#define SOF_INTERRUPT                                          0
> -       /* offset 0x0030 */
> -       __le32                  idxaddr;
> -       __le32                  idxdata;
> -       __le32                  fifoctl;
> -#define PCI_BASE2_RANGE                                                16
> -#define IGNORE_FIFO_AVAILABILITY                               3
> -#define PCI_BASE2_SELECT                                       2
> -#define FIFO_CONFIGURATION_SELECT                              0
> -       u32                     _unused2;
> -       /* offset 0x0040 */
> -       __le32                  memaddr;
> -#define START                                                  28
> -#define DIRECTION                                              27
> -#define FIFO_DIAGNOSTIC_SELECT                                 24
> -#define MEMORY_ADDRESS                                         0
> -       __le32                  memdata0;
> -       __le32                  memdata1;
> -       u32                     _unused3;
> -       /* offset 0x0050 */
> -       __le32                  gpioctl;
> -#define GPIO3_LED_SELECT                                       12
> -#define GPIO3_INTERRUPT_ENABLE                                 11
> -#define GPIO2_INTERRUPT_ENABLE                                 10
> -#define GPIO1_INTERRUPT_ENABLE                                 9
> -#define GPIO0_INTERRUPT_ENABLE                                 8
> -#define GPIO3_OUTPUT_ENABLE                                    7
> -#define GPIO2_OUTPUT_ENABLE                                    6
> -#define GPIO1_OUTPUT_ENABLE                                    5
> -#define GPIO0_OUTPUT_ENABLE                                    4
> -#define GPIO3_DATA                                             3
> -#define GPIO2_DATA                                             2
> -#define GPIO1_DATA                                             1
> -#define GPIO0_DATA                                             0
> -       __le32                  gpiostat;
> -#define GPIO3_INTERRUPT                                                3
> -#define GPIO2_INTERRUPT                                                2
> -#define GPIO1_INTERRUPT                                                1
> -#define GPIO0_INTERRUPT                                                0
> -} __packed;
> -
> -/* usb control, BAR0 + 0x0080 */
> -struct net2280_usb_regs {
> -       /* offset 0x0080 */
> -       __le32                  stdrsp;
> -#define STALL_UNSUPPORTED_REQUESTS                             31
> -#define SET_TEST_MODE                                          16
> -#define GET_OTHER_SPEED_CONFIGURATION                          15
> -#define GET_DEVICE_QUALIFIER                                   14
> -#define SET_ADDRESS                                            13
> -#define ENDPOINT_SET_CLEAR_HALT                                        12
> -#define DEVICE_SET_CLEAR_DEVICE_REMOTE_WAKEUP                  11
> -#define GET_STRING_DESCRIPTOR_2                                        10
> -#define GET_STRING_DESCRIPTOR_1                                        9
> -#define GET_STRING_DESCRIPTOR_0                                        8
> -#define GET_SET_INTERFACE                                      6
> -#define GET_SET_CONFIGURATION                                  5
> -#define GET_CONFIGURATION_DESCRIPTOR                           4
> -#define GET_DEVICE_DESCRIPTOR                                  3
> -#define GET_ENDPOINT_STATUS                                    2
> -#define GET_INTERFACE_STATUS                                   1
> -#define GET_DEVICE_STATUS                                      0
> -       __le32                  prodvendid;
> -#define     PRODUCT_ID                                         16
> -#define     VENDOR_ID                                          0
> -       __le32                  relnum;
> -       __le32                  usbctl;
> -#define SERIAL_NUMBER_INDEX                                    16
> -#define PRODUCT_ID_STRING_ENABLE                               13
> -#define VENDOR_ID_STRING_ENABLE                                        12
> -#define USB_ROOT_PORT_WAKEUP_ENABLE                            11
> -#define VBUS_PIN                                               10
> -#define TIMED_DISCONNECT                                       9
> -#define SUSPEND_IMMEDIATELY                                    7
> -#define SELF_POWERED_USB_DEVICE                                        6
> -#define REMOTE_WAKEUP_SUPPORT                                  5
> -#define PME_POLARITY                                           4
> -#define USB_DETECT_ENABLE                                      3
> -#define PME_WAKEUP_ENABLE                                      2
> -#define DEVICE_REMOTE_WAKEUP_ENABLE                            1
> -#define SELF_POWERED_STATUS                                    0
> -       /* offset 0x0090 */
> -       __le32                  usbstat;
> -#define HIGH_SPEED                                             7
> -#define FULL_SPEED                                             6
> -#define GENERATE_RESUME                                                5
> -#define GENERATE_DEVICE_REMOTE_WAKEUP                          4
> -       __le32                  xcvrdiag;
> -#define FORCE_HIGH_SPEED_MODE                                  31
> -#define FORCE_FULL_SPEED_MODE                                  30
> -#define USB_TEST_MODE                                          24
> -#define LINE_STATE                                             16
> -#define TRANSCEIVER_OPERATION_MODE                             2
> -#define TRANSCEIVER_SELECT                                     1
> -#define TERMINATION_SELECT                                     0
> -       __le32                  setup0123;
> -       __le32                  setup4567;
> -       /* offset 0x0090 */
> -       u32                     _unused0;
> -       __le32                  ouraddr;
> -#define FORCE_IMMEDIATE                                                7
> -#define OUR_USB_ADDRESS                                                0
> -       __le32                  ourconfig;
> -} __packed;
> -
> -/* pci control, BAR0 + 0x0100 */
> -struct net2280_pci_regs {
> -       /* offset 0x0100 */
> -       __le32                  pcimstctl;
> -#define PCI_ARBITER_PARK_SELECT                                        13
> -#define PCI_MULTI LEVEL_ARBITER                                        12
> -#define PCI_RETRY_ABORT_ENABLE                                 11
> -#define DMA_MEMORY_WRITE_AND_INVALIDATE_ENABLE                 10
> -#define DMA_READ_MULTIPLE_ENABLE                               9
> -#define DMA_READ_LINE_ENABLE                                   8
> -#define PCI_MASTER_COMMAND_SELECT                              6
> -#define                MEM_READ_OR_WRITE                               0
> -#define                IO_READ_OR_WRITE                                1
> -#define                CFG_READ_OR_WRITE                               2
> -#define PCI_MASTER_START                                       5
> -#define PCI_MASTER_READ_WRITE                                  4
> -#define                PCI_MASTER_WRITE                                0
> -#define                PCI_MASTER_READ                                 1
> -#define PCI_MASTER_BYTE_WRITE_ENABLES                          0
> -       __le32                  pcimstaddr;
> -       __le32                  pcimstdata;
> -       __le32                  pcimststat;
> -#define PCI_ARBITER_CLEAR                                      2
> -#define PCI_EXTERNAL_ARBITER                                   1
> -#define PCI_HOST_MODE                                          0
> -} __packed;
> -
> -/* dma control, BAR0 + 0x0180 ... array of four structs like this,
> - * for channels 0..3.  see also struct net2280_dma:  descriptor
> - * that can be loaded into some of these registers.
> - */
> -struct net2280_dma_regs {      /* [11.7] */
> -       /* offset 0x0180, 0x01a0, 0x01c0, 0x01e0, */
> -       __le32                  dmactl;
> -#define DMA_SCATTER_GATHER_DONE_INTERRUPT_ENABLE               25
> -#define DMA_CLEAR_COUNT_ENABLE                                 21
> -#define DESCRIPTOR_POLLING_RATE                                        19
> -#define                POLL_CONTINUOUS                                 0
> -#define                POLL_1_USEC                                     1
> -#define                POLL_100_USEC                                   2
> -#define                POLL_1_MSEC                                     3
> -#define DMA_VALID_BIT_POLLING_ENABLE                           18
> -#define DMA_VALID_BIT_ENABLE                                   17
> -#define DMA_SCATTER_GATHER_ENABLE                              16
> -#define DMA_OUT_AUTO_START_ENABLE                              4
> -#define DMA_PREEMPT_ENABLE                                     3
> -#define DMA_FIFO_VALIDATE                                      2
> -#define DMA_ENABLE                                             1
> -#define DMA_ADDRESS_HOLD                                       0
> -       __le32                  dmastat;
> -#define DMA_SCATTER_GATHER_DONE_INTERRUPT                      25
> -#define DMA_TRANSACTION_DONE_INTERRUPT                         24
> -#define DMA_ABORT                                              1
> -#define DMA_START                                              0
> -       u32                     _unused0[2];
> -       /* offset 0x0190, 0x01b0, 0x01d0, 0x01f0, */
> -       __le32                  dmacount;
> -#define VALID_BIT                                              31
> -#define DMA_DIRECTION                                          30
> -#define DMA_DONE_INTERRUPT_ENABLE                              29
> -#define END_OF_CHAIN                                           28
> -#define DMA_BYTE_COUNT_MASK                                    ((1<<24)-1)
> -#define DMA_BYTE_COUNT                                         0
> -       __le32                  dmaaddr;
> -       __le32                  dmadesc;
> -       u32                     _unused1;
> -} __packed;
> -
> -/* dedicated endpoint registers, BAR0 + 0x0200 */
> -
> -struct net2280_dep_regs {      /* [11.8] */
> -       /* offset 0x0200, 0x0210, 0x220, 0x230, 0x240 */
> -       __le32                  dep_cfg;
> -       /* offset 0x0204, 0x0214, 0x224, 0x234, 0x244 */
> -       __le32                  dep_rsp;
> -       u32                     _unused[2];
> -} __packed;
> -
> -/* configurable endpoint registers, BAR0 + 0x0300 ... array of seven structs
> - * like this, for ep0 then the configurable endpoints A..F
> - * ep0 reserved for control; E and F have only 64 bytes of fifo
> - */
> -struct net2280_ep_regs {       /* [11.9] */
> -       /* offset 0x0300, 0x0320, 0x0340, 0x0360, 0x0380, 0x03a0, 0x03c0 */
> -       __le32                  ep_cfg;
> -#define ENDPOINT_BYTE_COUNT                                    16
> -#define ENDPOINT_ENABLE                                                10
> -#define ENDPOINT_TYPE                                          8
> -#define ENDPOINT_DIRECTION                                     7
> -#define ENDPOINT_NUMBER                                                0
> -       __le32                  ep_rsp;
> -#define SET_NAK_OUT_PACKETS                                    15
> -#define SET_EP_HIDE_STATUS_PHASE                               14
> -#define SET_EP_FORCE_CRC_ERROR                                 13
> -#define SET_INTERRUPT_MODE                                     12
> -#define SET_CONTROL_STATUS_PHASE_HANDSHAKE                     11
> -#define SET_NAK_OUT_PACKETS_MODE                               10
> -#define SET_ENDPOINT_TOGGLE                                    9
> -#define SET_ENDPOINT_HALT                                      8
> -#define CLEAR_NAK_OUT_PACKETS                                  7
> -#define CLEAR_EP_HIDE_STATUS_PHASE                             6
> -#define CLEAR_EP_FORCE_CRC_ERROR                               5
> -#define CLEAR_INTERRUPT_MODE                                   4
> -#define CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE                   3
> -#define CLEAR_NAK_OUT_PACKETS_MODE                             2
> -#define CLEAR_ENDPOINT_TOGGLE                                  1
> -#define CLEAR_ENDPOINT_HALT                                    0
> -       __le32                  ep_irqenb;
> -#define SHORT_PACKET_OUT_DONE_INTERRUPT_ENABLE                 6
> -#define SHORT_PACKET_TRANSFERRED_INTERRUPT_ENABLE              5
> -#define DATA_PACKET_RECEIVED_INTERRUPT_ENABLE                  3
> -#define DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE               2
> -#define DATA_OUT_PING_TOKEN_INTERRUPT_ENABLE                   1
> -#define DATA_IN_TOKEN_INTERRUPT_ENABLE                         0
> -       __le32                  ep_stat;
> -#define FIFO_VALID_COUNT                                       24
> -#define HIGH_BANDWIDTH_OUT_TRANSACTION_PID                     22
> -#define TIMEOUT                                                        21
> -#define USB_STALL_SENT                                         20
> -#define USB_IN_NAK_SENT                                                19
> -#define USB_IN_ACK_RCVD                                                18
> -#define USB_OUT_PING_NAK_SENT                                  17
> -#define USB_OUT_ACK_SENT                                       16
> -#define FIFO_OVERFLOW                                          13
> -#define FIFO_UNDERFLOW                                         12
> -#define FIFO_FULL                                              11
> -#define FIFO_EMPTY                                             10
> -#define FIFO_FLUSH                                             9
> -#define SHORT_PACKET_OUT_DONE_INTERRUPT                                6
> -#define SHORT_PACKET_TRANSFERRED_INTERRUPT                     5
> -#define NAK_OUT_PACKETS                                                4
> -#define DATA_PACKET_RECEIVED_INTERRUPT                         3
> -#define DATA_PACKET_TRANSMITTED_INTERRUPT                      2
> -#define DATA_OUT_PING_TOKEN_INTERRUPT                          1
> -#define DATA_IN_TOKEN_INTERRUPT                                        0
> -       /* offset 0x0310, 0x0330, 0x0350, 0x0370, 0x0390, 0x03b0, 0x03d0 */
> -       __le32                  ep_avail;
> -       __le32                  ep_data;
> -       u32                     _unused0[2];
> -} __packed;
> -
> -struct net2280_reg_write {
> -       __le16 port;
> -       __le32 addr;
> -       __le32 val;
> -} __packed;
> -
> -struct net2280_reg_read {
> -       __le16 port;
> -       __le32 addr;
> -} __packed;
> -#endif /* NET2280_H */
> diff --git a/drivers/net/wireless/p54/p54usb.h b/drivers/net/wireless/p54/p54usb.h
> index d273be7..a5f5f0f 100644
> --- a/drivers/net/wireless/p54/p54usb.h
> +++ b/drivers/net/wireless/p54/p54usb.h
> @@ -16,7 +16,7 @@
>
>  /* for isl3886 register definitions used on ver 1 devices */
>  #include "p54pci.h"
> -#include "net2280.h"
> +#include <linux/usb/net2280.h>
>
>  /* pci */
>  #define NET2280_BASE           0x10000000
> @@ -93,6 +93,17 @@ enum net2280_op_type {
>         NET2280_DEV_CFG_U16     = 0x0883
>  };
>
> +struct net2280_reg_write {
> +       __le16 port;
> +       __le32 addr;
> +       __le32 val;
> +} __packed;
> +
> +struct net2280_reg_read {
> +       __le16 port;
> +       __le32 addr;
> +} __packed;
> +
>  #define P54U_FW_BLOCK 2048
>
>  #define X2_SIGNATURE "x2  "
> --
> 2.1.3
>



-- 
Ricardo Ribalda

^ permalink raw reply

* Re: [PATCH RFC v4 net-next 0/5] virtio_net: enabling tx interrupts
From: Michael S. Tsirkin @ 2014-12-01 10:42 UTC (permalink / raw)
  To: Jason Wang; +Cc: pagupta, netdev, davem, linux-kernel, virtualization
In-Reply-To: <1417429028-11971-1-git-send-email-jasowang@redhat.com>

On Mon, Dec 01, 2014 at 06:17:03PM +0800, Jason Wang wrote:
> Hello:
> 
> We used to orphan packets before transmission for virtio-net. This breaks
> socket accounting and can lead serveral functions won't work, e.g:
> 
> - Byte Queue Limit depends on tx completion nofication to work.
> - Packet Generator depends on tx completion nofication for the last
>   transmitted packet to complete.
> - TCP Small Queue depends on proper accounting of sk_wmem_alloc to work.
> 
> This series tries to solve the issue by enabling tx interrupts. To minize
> the performance impacts of this, several optimizations were used:
> 
> - In guest side, virtqueue_enable_cb_delayed() was used to delay the tx
>   interrupt untile 3/4 pending packets were sent.
> - In host side, interrupt coalescing were used to reduce tx interrupts.
> 
> Performance test results[1] (tx-frames 16 tx-usecs 16) shows:
> 
> - For guest receiving. No obvious regression on throughput were
>   noticed. More cpu utilization were noticed in few cases.
> - For guest transmission. Very huge improvement on througput for small
>   packet transmission were noticed. This is expected since TSQ and other
>   optimization for small packet transmission work after tx interrupt. But
>   will use more cpu for large packets.
> - For TCP_RR, regression (10% on transaction rate and cpu utilization) were
>   found. Tx interrupt won't help but cause overhead in this case. Using
>   more aggressive coalescing parameters may help to reduce the regression.

OK, you do have posted coalescing patches - does it help any?

I'm not sure the regression is due to interrupts.
It would make sense for CPU but why would it
hurt transaction rate?

It's possible that we are deferring kicks too much due to BQL.

As an experiment: do we get any of it back if we do
-        if (kick || netif_xmit_stopped(txq))
-                virtqueue_kick(sq->vq);
+        virtqueue_kick(sq->vq);
?

If yes, we can just kick e.g. periodically, e.g. after queueing each
X bytes.

> Changes from RFC V3:
> - Don't free tx packets in ndo_start_xmit()
> - Add interrupt coalescing support for virtio-net
> Changes from RFC v2:
> - clean up code, address issues raised by Jason
> Changes from RFC v1:
> - address comments by Jason Wang, use delayed cb everywhere
> - rebased Jason's patch on top of mine and include it (with some tweaks)
> 
> Please reivew. Comments were more than welcomed.
> 
> [1] Performance Test result:
> 
> Environment:
> - Two Intel(R) Xeon(R) CPU E5620 @ 2.40GHz machines connected back to back
>   with 82599ES cards.
> - Both host and guest were net-next.git plus the patch
> - Coalescing parameters for the card:
>   Adaptive RX: off  TX: off
>   rx-usecs: 1
>   rx-frames: 0
>   tx-usecs: 0
>   tx-frames: 0
> - Vhost_net was enabled and zerocopy was disabled
> - Tests was done by netperf-2.6
> - Guest has 2 vcpus with single queue virtio-net
> 
> Results:
> - Numbers of square brackets are whose significance is grater than 95%
> 
> Guest RX:
> 
> size/sessions/+throughput/+cpu/+per_cpu_throughput/
> 64/1/+2.0326/[+6.2807%]/-3.9970%/
> 64/2/-0.2104%/[+3.2012%]/[-3.3058%]/
> 64/4/+1.5956%/+2.2451%/-0.6353%/
> 64/8/+1.1732%/+3.5123%/-2.2598%/
> 256/1/+3.7619%/[+5.8117%]/-1.9372%/
> 256/2/-0.0661%/[+3.2511%]/-3.2127%/
> 256/4/+1.1435%/[-8.1842%]/[+10.1591%]/
> 256/8/[+2.2447%]/[+6.2044%]/[-3.7283%]/
> 1024/1/+9.1479%/[+12.0997%]/[-2.6332%]/
> 1024/2/[-17.3341%]/[+0.0000%]/[-17.3341%]/
> 1024/4/[-0.6284%]/-1.0376%/+0.4135%/
> 1024/8/+1.1444%/-1.6069%/+2.7961%/
> 4096/1/+0.0401%/-0.5993%/+0.6433%/
> 4096/2/[-0.5894%]/-2.2071%/+1.6542%/
> 4096/4/[-0.5560%]/-1.4969%/+0.9553%/
> 4096/8/-0.3362%/+2.7086%/-2.9645%/
> 16384/1/-0.0285%/+0.7247%/-0.7478%/
> 16384/2/-0.5286%/+0.3287%/-0.8545%/
> 16384/4/-0.3297%/-2.0543%/+1.7608%/
> 16384/8/+1.0932%/+4.0253%/-2.8187%/
> 65535/1/+0.0003%/-0.1502%/+0.1508%/
> 65535/2/[-0.6065%]/+0.2309%/-0.8355%/
> 65535/4/[-0.6861%]/[+3.9451%]/[-4.4554%]/
> 65535/8/+1.8359%/+3.1590%/-1.2825%/
> 
> Guest RX:
> size/sessions/+throughput/+cpu/+per_cpu_throughput/
> 64/1/[+65.0961%]/[-8.6807%]/[+80.7900%]/
> 64/2/[+6.0288%]/[-2.2823%]/[+8.5052%]/
> 64/4/[+5.9038%]/[-2.1834%]/[+8.2677%]/
> 64/8/[+5.4154%]/[-2.1804%]/[+7.7651%]/
> 256/1/[+184.6462%]/[+4.8906%]/[+171.3742%]/
> 256/2/[+46.0731%]/[-8.9626%]/[+60.4539%]/
> 256/4/[+45.8547%]/[-8.3027%]/[+59.0612%]/
> 256/8/[+45.3486%]/[-8.4024%]/[+58.6817%]/
> 1024/1/[+432.5372%]/[+3.9566%]/[+412.2689%]/
> 1024/2/[-1.4207%]/[-23.6426%]/[+29.1025%]/
> 1024/4/-0.1003%/[-13.6416%]/[+15.6804%]/
> 1024/8/[+0.2200%]/[+2.0634%]/[-1.8061%]/
> 4096/1/[+18.4835%]/[-46.1508%]/[+120.0283%]/
> 4096/2/+0.1770%/[-26.2780%]/[+35.8848%]/
> 4096/4/-0.1012%/-0.7353%/+0.6388%/
> 4096/8/-0.6091%/+1.4159%/-1.9968%/
> 16384/1/-0.0424%/[+11.9373%]/[-10.7021%]/
> 16384/2/+0.0482%/+2.4685%/-2.3620%/
> 16384/4/+0.0840%/[+5.3587%]/[-5.0064%]/
> 16384/8/+0.0048%/[+5.0176%]/[-4.7733%]/
> 65535/1/-0.0095%/[+10.9408%]/[-9.8705%]/
> 65535/2/+0.1515%/[+8.1709%]/[-7.4137%]/
> 65535/4/+0.0203%/[+5.4316%]/[-5.1325%]/
> 65535/8/+0.1427%/[+6.2753%]/[-5.7705%]/
> 
> size/sessions/+trans.rate/+cpu/+per_cpu_trans.rate/
> 64/1/+0.2346%/[+11.5080%]/[-10.1099%]/
> 64/25/[-10.7893%]/-0.5791%/[-10.2697%]/
> 64/50/[-11.5997%]/-0.3429%/[-11.2956%]/
> 256/1/+0.7219%/[+13.2374%]/[-11.0524%]/
> 256/25/-6.9567%/+0.8887%/[-7.7763%]/
> 256/50/[-4.8814%]/-0.0338%/[-4.8492%]/
> 4096/1/-1.6061%/-0.7561%/-0.8565%/
> 4096/25/[+2.2120%]/[+1.0839%]/+1.1161%/
> 4096/50/[+5.6180%]/[+3.2116%]/[+2.3315%]/
> 
> Jason Wang (4):
>   virtio_net: enable tx interrupt
>   virtio-net: optimize free_old_xmit_skbs stats
>   virtio-net: add basic interrupt coalescing support
>   vhost_net: interrupt coalescing support
> 
> Michael S. Tsirkin (1):
>   virtio_net: bql
> 
>  drivers/net/virtio_net.c        | 211 ++++++++++++++++++++++++++++++++--------
>  drivers/vhost/net.c             | 200 +++++++++++++++++++++++++++++++++++--
>  include/uapi/linux/vhost.h      |  12 +++
>  include/uapi/linux/virtio_net.h |  12 +++
>  4 files changed, 383 insertions(+), 52 deletions(-)
> 
> -- 
> 1.8.3.1

^ permalink raw reply

* Re: [PATCH] mips: bpf: Fix broken BPF_MOD
From: Denis Kirjanov @ 2014-12-01 10:37 UTC (permalink / raw)
  To: Network Development; +Cc: stable, Markos Chandras
In-Reply-To: <547C3F2F.3070708@imgtec.com>

On 12/1/14, Markos Chandras <Markos.Chandras@imgtec.com> wrote:
> On 12/01/2014 09:57 AM, Denis Kirjanov wrote:
>> Remove optimize_div() from BPF_MOD | BPF_K case
>> since we don't know the dividend and fix the
>> emit_mod() by reading the mod operation result from HI register
>>
>> Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
>> ---
>>  arch/mips/net/bpf_jit.c |    4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/mips/net/bpf_jit.c b/arch/mips/net/bpf_jit.c
>> index 9b55143..9fd6834 100644
>> --- a/arch/mips/net/bpf_jit.c
>> +++ b/arch/mips/net/bpf_jit.c
>> @@ -426,7 +426,7 @@ static inline void emit_mod(unsigned int dst, unsigned
>> int src,
>>  		u32 *p = &ctx->target[ctx->idx];
>>  		uasm_i_divu(&p, dst, src);
>>  		p = &ctx->target[ctx->idx + 1];
>> -		uasm_i_mflo(&p, dst);
>> +		uasm_i_mfhi(&p, dst);
>
> That looks correct.
>
>>  	}
>>  	ctx->idx += 2; /* 2 insts */
>>  }
>> @@ -971,7 +971,7 @@ load_ind:
>>  			break;
>>  		case BPF_ALU | BPF_MOD | BPF_K:
>>  			/* A %= k */
>> -			if (k == 1 || optimize_div(&k)) {
>> +			if (k == 1) {
>>  				ctx->flags |= SEEN_A;
>>  				emit_jit_reg_move(r_A, r_zero, ctx);
>>  			} else {
>>
>
> That looks correct too. Thanks for fixing these.
>
> Can you also CC stable for inclusion in >=3.16?
>
> Reviewed-by: Markos Chandras <markos.chandras@imgtec.com>
Cc: stable@vger.kernel.org
> --
> markos
>

^ permalink raw reply

* Re: [PATCH RFC v4 net-next 1/5] virtio_net: enable tx interrupt
From: Michael S. Tsirkin @ 2014-12-01 10:35 UTC (permalink / raw)
  To: Jason Wang; +Cc: pagupta, netdev, linux-kernel, virtualization, davem
In-Reply-To: <1417429028-11971-2-git-send-email-jasowang@redhat.com>

On Mon, Dec 01, 2014 at 06:17:04PM +0800, Jason Wang wrote:
> On newer hosts that support delayed tx interrupts,
> we probably don't have much to gain from orphaning
> packets early.
> 
> Note: this might degrade performance for
> hosts without event idx support.
> Should be addressed by the next patch.
>
> Cc: Rusty Russell <rusty@rustcorp.com.au>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>

Could you document the changes from the RFC I sent please?
Are there optimizations?
If yes, it might be easier to review (at least for me), if you refactor this,
e.g. applying the straight-forward rfc patch and then optimizations if
any on top. If it's taking a different approach, pls feel free to
disregard this.


> ---
>  drivers/net/virtio_net.c | 132 +++++++++++++++++++++++++++++++----------------
>  1 file changed, 88 insertions(+), 44 deletions(-)
> 
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index ec2a8b4..f68114e 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -72,6 +72,8 @@ struct send_queue {
>  
>  	/* Name of the send queue: output.$index */
>  	char name[40];
> +
> +	struct napi_struct napi;
>  };
>  
>  /* Internal representation of a receive virtqueue */
> @@ -137,6 +139,9 @@ struct virtnet_info {
>  
>  	/* CPU hot plug notifier */
>  	struct notifier_block nb;
> +
> +	/* Budget for polling tx completion */
> +	u32 tx_work_limit;
>  };
>  
>  struct skb_vnet_hdr {
> @@ -211,15 +216,41 @@ static struct page *get_a_page(struct receive_queue *rq, gfp_t gfp_mask)
>  	return p;
>  }
>  
> +static unsigned int free_old_xmit_skbs(struct netdev_queue *txq,
> +				       struct send_queue *sq, int budget)
> +{
> +	struct sk_buff *skb;
> +	unsigned int len;
> +	struct virtnet_info *vi = sq->vq->vdev->priv;
> +	struct virtnet_stats *stats = this_cpu_ptr(vi->stats);
> +	unsigned int packets = 0;
> +
> +	while (packets < budget &&
> +	       (skb = virtqueue_get_buf(sq->vq, &len)) != NULL) {
> +		pr_debug("Sent skb %p\n", skb);
> +
> +		u64_stats_update_begin(&stats->tx_syncp);
> +		stats->tx_bytes += skb->len;
> +		stats->tx_packets++;
> +		u64_stats_update_end(&stats->tx_syncp);
> +
> +		dev_kfree_skb_any(skb);
> +		packets++;
> +	}
> +
> +	if (sq->vq->num_free >= 2+MAX_SKB_FRAGS)
> +		netif_tx_start_queue(txq);
> +
> +	return packets;
> +}
> +
>  static void skb_xmit_done(struct virtqueue *vq)
>  {
>  	struct virtnet_info *vi = vq->vdev->priv;
> +	struct send_queue *sq = &vi->sq[vq2txq(vq)];
>  
> -	/* Suppress further interrupts. */
> -	virtqueue_disable_cb(vq);
> -
> -	/* We were probably waiting for more output buffers. */
> -	netif_wake_subqueue(vi->dev, vq2txq(vq));
> +	virtqueue_disable_cb(sq->vq);
> +	napi_schedule(&sq->napi);
>  }
>  
>  static unsigned int mergeable_ctx_to_buf_truesize(unsigned long mrg_ctx)
> @@ -777,6 +808,32 @@ again:
>  	return received;
>  }
>  
> +static int virtnet_poll_tx(struct napi_struct *napi, int budget)
> +{
> +	struct send_queue *sq =
> +		container_of(napi, struct send_queue, napi);
> +	struct virtnet_info *vi = sq->vq->vdev->priv;
> +	struct netdev_queue *txq = netdev_get_tx_queue(vi->dev, vq2txq(sq->vq));
> +	u32 limit = vi->tx_work_limit;
> +	unsigned int sent;
> +
> +	__netif_tx_lock(txq, smp_processor_id());
> +	sent = free_old_xmit_skbs(txq, sq, limit);
> +	if (sent < limit) {
> +		napi_complete(napi);
> +		/* Note: we must enable cb *after* napi_complete, because
> +		 * napi_schedule calls from callbacks that trigger before
> +		 * napi_complete are ignored.
> +		 */
> +		if (unlikely(!virtqueue_enable_cb_delayed(sq->vq))) {
> +			virtqueue_disable_cb(sq->vq);
> +			napi_schedule(&sq->napi);
> +		}
> +	}
> +	__netif_tx_unlock(txq);
> +	return sent < limit ? 0 : budget;
> +}
> +

Unlike the patch I sent, this seems to ignore the budget,
and always poll the full napi_weight.
Seems strange.  What is the reason for this?



>  #ifdef CONFIG_NET_RX_BUSY_POLL
>  /* must be called with local_bh_disable()d */
>  static int virtnet_busy_poll(struct napi_struct *napi)
> @@ -825,30 +882,12 @@ static int virtnet_open(struct net_device *dev)
>  			if (!try_fill_recv(&vi->rq[i], GFP_KERNEL))
>  				schedule_delayed_work(&vi->refill, 0);
>  		virtnet_napi_enable(&vi->rq[i]);
> +		napi_enable(&vi->sq[i].napi);
>  	}
>  
>  	return 0;
>  }
>  
> -static void free_old_xmit_skbs(struct send_queue *sq)
> -{
> -	struct sk_buff *skb;
> -	unsigned int len;
> -	struct virtnet_info *vi = sq->vq->vdev->priv;
> -	struct virtnet_stats *stats = this_cpu_ptr(vi->stats);
> -
> -	while ((skb = virtqueue_get_buf(sq->vq, &len)) != NULL) {
> -		pr_debug("Sent skb %p\n", skb);
> -
> -		u64_stats_update_begin(&stats->tx_syncp);
> -		stats->tx_bytes += skb->len;
> -		stats->tx_packets++;
> -		u64_stats_update_end(&stats->tx_syncp);
> -
> -		dev_kfree_skb_any(skb);
> -	}
> -}
> -
>  static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)
>  {
>  	struct skb_vnet_hdr *hdr;
> @@ -912,7 +951,9 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)
>  		sg_set_buf(sq->sg, hdr, hdr_len);
>  		num_sg = skb_to_sgvec(skb, sq->sg + 1, 0, skb->len) + 1;
>  	}
> -	return virtqueue_add_outbuf(sq->vq, sq->sg, num_sg, skb, GFP_ATOMIC);
> +
> +	return virtqueue_add_outbuf(sq->vq, sq->sg, num_sg, skb,
> +				    GFP_ATOMIC);
>  }
>  
>  static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
> @@ -924,8 +965,7 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
>  	struct netdev_queue *txq = netdev_get_tx_queue(dev, qnum);
>  	bool kick = !skb->xmit_more;
>  
> -	/* Free up any pending old buffers before queueing new ones. */
> -	free_old_xmit_skbs(sq);
> +	virtqueue_disable_cb(sq->vq);
>  
>  	/* Try to transmit */
>  	err = xmit_skb(sq, skb);
> @@ -941,27 +981,19 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
>  		return NETDEV_TX_OK;
>  	}
>  
> -	/* Don't wait up for transmitted skbs to be freed. */
> -	skb_orphan(skb);
> -	nf_reset(skb);
> -
>  	/* Apparently nice girls don't return TX_BUSY; stop the queue
>  	 * before it gets out of hand.  Naturally, this wastes entries. */
> -	if (sq->vq->num_free < 2+MAX_SKB_FRAGS) {
> +	if (sq->vq->num_free < 2+MAX_SKB_FRAGS)
>  		netif_stop_subqueue(dev, qnum);
> -		if (unlikely(!virtqueue_enable_cb_delayed(sq->vq))) {
> -			/* More just got used, free them then recheck. */
> -			free_old_xmit_skbs(sq);
> -			if (sq->vq->num_free >= 2+MAX_SKB_FRAGS) {
> -				netif_start_subqueue(dev, qnum);
> -				virtqueue_disable_cb(sq->vq);
> -			}
> -		}
> -	}
>  
>  	if (kick || netif_xmit_stopped(txq))
>  		virtqueue_kick(sq->vq);
>  
> +	if (unlikely(!virtqueue_enable_cb_delayed(sq->vq))) {
> +		virtqueue_disable_cb(sq->vq);
> +		napi_schedule(&sq->napi);
> +	}
> +
>  	return NETDEV_TX_OK;
>  }
>  
> @@ -1138,8 +1170,10 @@ static int virtnet_close(struct net_device *dev)
>  	/* Make sure refill_work doesn't re-enable napi! */
>  	cancel_delayed_work_sync(&vi->refill);
>  
> -	for (i = 0; i < vi->max_queue_pairs; i++)
> +	for (i = 0; i < vi->max_queue_pairs; i++) {
>  		napi_disable(&vi->rq[i].napi);
> +		napi_disable(&vi->sq[i].napi);
> +	}
>  
>  	return 0;
>  }
> @@ -1452,8 +1486,10 @@ static void virtnet_free_queues(struct virtnet_info *vi)
>  {
>  	int i;
>  
> -	for (i = 0; i < vi->max_queue_pairs; i++)
> +	for (i = 0; i < vi->max_queue_pairs; i++) {
>  		netif_napi_del(&vi->rq[i].napi);
> +		netif_napi_del(&vi->sq[i].napi);
> +	}
>  
>  	kfree(vi->rq);
>  	kfree(vi->sq);
> @@ -1607,6 +1643,8 @@ static int virtnet_alloc_queues(struct virtnet_info *vi)
>  		netif_napi_add(vi->dev, &vi->rq[i].napi, virtnet_poll,
>  			       napi_weight);
>  		napi_hash_add(&vi->rq[i].napi);
> +		netif_napi_add(vi->dev, &vi->sq[i].napi, virtnet_poll_tx,
> +			       napi_weight);
>  
>  		sg_init_table(vi->rq[i].sg, ARRAY_SIZE(vi->rq[i].sg));
>  		ewma_init(&vi->rq[i].mrg_avg_pkt_len, 1, RECEIVE_AVG_WEIGHT);
> @@ -1790,6 +1828,8 @@ static int virtnet_probe(struct virtio_device *vdev)
>  	if (err)
>  		goto free_stats;
>  
> +	vi->tx_work_limit = napi_weight;
> +
>  #ifdef CONFIG_SYSFS
>  	if (vi->mergeable_rx_bufs)
>  		dev->sysfs_rx_queue_group = &virtio_net_mrg_rx_group;
> @@ -1904,8 +1944,10 @@ static int virtnet_freeze(struct virtio_device *vdev)
>  	if (netif_running(vi->dev)) {
>  		for (i = 0; i < vi->max_queue_pairs; i++) {
>  			napi_disable(&vi->rq[i].napi);
> +			napi_disable(&vi->sq[i].napi);
>  			napi_hash_del(&vi->rq[i].napi);
>  			netif_napi_del(&vi->rq[i].napi);
> +			netif_napi_del(&vi->sq[i].napi);
>  		}
>  	}
>  
> @@ -1930,8 +1972,10 @@ static int virtnet_restore(struct virtio_device *vdev)
>  			if (!try_fill_recv(&vi->rq[i], GFP_KERNEL))
>  				schedule_delayed_work(&vi->refill, 0);
>  
> -		for (i = 0; i < vi->max_queue_pairs; i++)
> +		for (i = 0; i < vi->max_queue_pairs; i++) {
>  			virtnet_napi_enable(&vi->rq[i]);
> +			napi_enable(&vi->sq[i].napi);
> +		}
>  	}
>  
>  	netif_device_attach(vi->dev);
> -- 
> 1.8.3.1

^ permalink raw reply

* Re: [bisected] xfrm: TCP connection initiating PMTU discovery stalls on v3.12+
From: Herbert Xu @ 2014-12-01 10:25 UTC (permalink / raw)
  To: Thomas Jarosch; +Cc: netdev, edumazet, Steffen Klassert
In-Reply-To: <1709726.jUgUSQI9sl@pikkukde.a.i2n>

Thomas Jarosch <thomas.jarosch@intra2net.com> wrote:
> 
> When I revert it, even kernel v3.18-rc6 starts working.
> But I doubt this is the root problem, may be just hiding another issue.

Can you do a tcpdump with this patch reverted? I would like to
see the size of the packets that are sent out vs. the ICMP message
that came back.

My guess is that the IPsec GSO path is buggy since as you rightly
pointed out it couldn't have been heavily tested prior to this
patch.

Though I am surprised that it only breaks when you have a PMTU event
so it might be something else after all.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply

* [PATCH RFC v4 net-next 5/5] vhost_net: interrupt coalescing support
From: Jason Wang @ 2014-12-01 10:17 UTC (permalink / raw)
  To: mst, virtualization, netdev, linux-kernel, davem; +Cc: pagupta
In-Reply-To: <1417429028-11971-1-git-send-email-jasowang@redhat.com>

This patch implements interrupt coalescing support for vhost_net. And provides
ioctl()s for userspace to get and set coalescing parameters. Two kinds of
parameters were allowed to be set:

- max_coalesced_frames: which is the maximum numbers of packets were allowed
  before issuing an irq.
- coalesced_usecs: which is the maximum number of micro seconds were allowed
  before issuing an irq if at least one packet were pending.

A per virtqueue hrtimer were used for coalesced_usecs.

Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/vhost/net.c        | 200 +++++++++++++++++++++++++++++++++++++++++++--
 include/uapi/linux/vhost.h |  12 +++
 2 files changed, 203 insertions(+), 9 deletions(-)

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 8dae2f7..c416aa7 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -18,6 +18,7 @@
 #include <linux/file.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
+#include <linux/timer.h>
 
 #include <linux/net.h>
 #include <linux/if_packet.h>
@@ -61,7 +62,8 @@ MODULE_PARM_DESC(experimental_zcopytx, "Enable Zero Copy TX;"
 enum {
 	VHOST_NET_FEATURES = VHOST_FEATURES |
 			 (1ULL << VHOST_NET_F_VIRTIO_NET_HDR) |
-			 (1ULL << VIRTIO_NET_F_MRG_RXBUF),
+			 (1ULL << VIRTIO_NET_F_MRG_RXBUF) |
+			 (1ULL << VIRTIO_NET_F_CTRL_COALESCE)
 };
 
 enum {
@@ -99,6 +101,15 @@ struct vhost_net_virtqueue {
 	/* Reference counting for outstanding ubufs.
 	 * Protected by vq mutex. Writers must also take device mutex. */
 	struct vhost_net_ubuf_ref *ubufs;
+	/* Microseconds after at least 1 paket is processed before
+	 * generating an interrupt.
+	 */
+	__u32 coalesce_usecs;
+	/* Packets are processed before genearting an interrupt. */
+	__u32 max_coalesced_frames;
+	__u32 coalesced;
+	ktime_t last_signal;
+	struct hrtimer c_timer;
 };
 
 struct vhost_net {
@@ -196,11 +207,16 @@ static void vhost_net_vq_reset(struct vhost_net *n)
 	vhost_net_clear_ubuf_info(n);
 
 	for (i = 0; i < VHOST_NET_VQ_MAX; i++) {
+		hrtimer_cancel(&n->vqs[i].c_timer);
 		n->vqs[i].done_idx = 0;
 		n->vqs[i].upend_idx = 0;
 		n->vqs[i].ubufs = NULL;
 		n->vqs[i].vhost_hlen = 0;
 		n->vqs[i].sock_hlen = 0;
+		n->vqs[i].max_coalesced_frames = 0;
+		n->vqs[i].coalesce_usecs = 0;
+		n->vqs[i].last_signal = ktime_get();
+		n->vqs[i].coalesced = 0;
 	}
 
 }
@@ -272,6 +288,56 @@ static void copy_iovec_hdr(const struct iovec *from, struct iovec *to,
 	}
 }
 
+static int vhost_net_check_coalesce_and_signal(struct vhost_dev *dev,
+					       struct vhost_net_virtqueue *nvq)
+{
+	struct vhost_virtqueue *vq = &nvq->vq;
+	int left = 0;
+	ktime_t now;
+
+	if (nvq->coalesced) {
+		now = ktime_get();
+		left = nvq->coalesce_usecs -
+		       ktime_to_us(ktime_sub(now, nvq->last_signal));
+		if (left <= 0) {
+			vhost_signal(dev, vq);
+			nvq->last_signal = now;
+			nvq->coalesced = 0;
+		}
+	}
+
+	return left;
+}
+
+static bool vhost_net_add_used_and_signal_n(struct vhost_dev *dev,
+					    struct vhost_net_virtqueue *nvq,
+					    struct vring_used_elem *heads,
+					    unsigned count)
+{
+	struct vhost_virtqueue *vq = &nvq->vq;
+	bool can_coalesce = nvq->max_coalesced_frames && nvq->coalesce_usecs;
+	bool ret = false;
+
+	vhost_add_used_n(vq, heads, count);
+
+	if (can_coalesce) {
+		ktime_t now = ktime_get();
+
+		nvq->coalesced += count;
+		if ((nvq->coalesced >= nvq->max_coalesced_frames) ||
+		    (ktime_to_us(ktime_sub(now, nvq->last_signal)) >=
+		     nvq->coalesce_usecs)) {
+			vhost_signal(dev, vq);
+			nvq->coalesced = 0;
+			nvq->last_signal = now;
+			ret = true;
+		}
+	} else {
+		vhost_signal(dev, vq);
+	}
+	return ret;
+}
+
 /* In case of DMA done not in order in lower device driver for some reason.
  * upend_idx is used to track end of used idx, done_idx is used to track head
  * of used idx. Once lower device DMA done contiguously, we will signal KVM
@@ -296,8 +362,8 @@ static void vhost_zerocopy_signal_used(struct vhost_net *net,
 	}
 	while (j) {
 		add = min(UIO_MAXIOV - nvq->done_idx, j);
-		vhost_add_used_and_signal_n(vq->dev, vq,
-					    &vq->heads[nvq->done_idx], add);
+		vhost_net_add_used_and_signal_n(vq->dev, nvq,
+						&vq->heads[nvq->done_idx], add);
 		nvq->done_idx = (nvq->done_idx + add) % UIO_MAXIOV;
 		j -= add;
 	}
@@ -351,6 +417,7 @@ static void handle_tx(struct vhost_net *net)
 	struct socket *sock;
 	struct vhost_net_ubuf_ref *uninitialized_var(ubufs);
 	bool zcopy, zcopy_used;
+	int left;
 
 	mutex_lock(&vq->mutex);
 	sock = vq->private_data;
@@ -362,6 +429,8 @@ static void handle_tx(struct vhost_net *net)
 	hdr_size = nvq->vhost_hlen;
 	zcopy = nvq->ubufs;
 
+	vhost_net_check_coalesce_and_signal(&net->dev, nvq);
+
 	for (;;) {
 		/* Release DMAs done buffers first */
 		if (zcopy)
@@ -444,10 +513,15 @@ static void handle_tx(struct vhost_net *net)
 		if (err != len)
 			pr_debug("Truncated TX packet: "
 				 " len %d != %zd\n", err, len);
-		if (!zcopy_used)
-			vhost_add_used_and_signal(&net->dev, vq, head, 0);
-		else
+
+		if (!zcopy_used) {
+			struct vring_used_elem heads = { head, 0 };
+
+			vhost_net_add_used_and_signal_n(&net->dev,
+							nvq, &heads, 1);
+		} else {
 			vhost_zerocopy_signal_used(net, vq);
+		}
 		total_len += len;
 		vhost_net_tx_packet(net);
 		if (unlikely(total_len >= VHOST_NET_WEIGHT)) {
@@ -455,6 +529,12 @@ static void handle_tx(struct vhost_net *net)
 			break;
 		}
 	}
+
+	left = vhost_net_check_coalesce_and_signal(&net->dev, nvq);
+	if (left > 0)
+		hrtimer_start(&nvq->c_timer, ms_to_ktime(left),
+			      HRTIMER_MODE_REL);
+
 out:
 	mutex_unlock(&vq->mutex);
 }
@@ -570,7 +650,7 @@ static void handle_rx(struct vhost_net *net)
 		.hdr.gso_type = VIRTIO_NET_HDR_GSO_NONE
 	};
 	size_t total_len = 0;
-	int err, mergeable;
+	int err, mergeable, left;
 	s16 headcount;
 	size_t vhost_hlen, sock_hlen;
 	size_t vhost_len, sock_len;
@@ -589,6 +669,8 @@ static void handle_rx(struct vhost_net *net)
 		vq->log : NULL;
 	mergeable = vhost_has_feature(vq, VIRTIO_NET_F_MRG_RXBUF);
 
+	vhost_net_check_coalesce_and_signal(&net->dev, nvq);
+
 	while ((sock_len = peek_head_len(sock->sk))) {
 		sock_len += sock_hlen;
 		vhost_len = sock_len + vhost_hlen;
@@ -654,8 +736,10 @@ static void handle_rx(struct vhost_net *net)
 			vhost_discard_vq_desc(vq, headcount);
 			break;
 		}
-		vhost_add_used_and_signal_n(&net->dev, vq, vq->heads,
-					    headcount);
+
+		vhost_net_add_used_and_signal_n(&net->dev, nvq,
+						vq->heads, headcount);
+
 		if (unlikely(vq_log))
 			vhost_log_write(vq, vq_log, log, vhost_len);
 		total_len += vhost_len;
@@ -664,6 +748,12 @@ static void handle_rx(struct vhost_net *net)
 			break;
 		}
 	}
+
+	left = vhost_net_check_coalesce_and_signal(&net->dev, nvq);
+	if (left > 0)
+		hrtimer_start(&nvq->c_timer, ms_to_ktime(left),
+			HRTIMER_MODE_REL);
+
 out:
 	mutex_unlock(&vq->mutex);
 }
@@ -700,6 +790,18 @@ static void handle_rx_net(struct vhost_work *work)
 	handle_rx(net);
 }
 
+static enum hrtimer_restart vhost_net_timer_handler(struct hrtimer *timer)
+{
+	struct vhost_net_virtqueue *nvq = container_of(timer,
+						struct vhost_net_virtqueue,
+						c_timer);
+	struct vhost_virtqueue *vq = &nvq->vq;
+
+	vhost_poll_queue(&vq->poll);
+
+	return HRTIMER_NORESTART;
+}
+
 static int vhost_net_open(struct inode *inode, struct file *f)
 {
 	struct vhost_net *n;
@@ -731,6 +833,13 @@ static int vhost_net_open(struct inode *inode, struct file *f)
 		n->vqs[i].done_idx = 0;
 		n->vqs[i].vhost_hlen = 0;
 		n->vqs[i].sock_hlen = 0;
+		n->vqs[i].max_coalesced_frames = 0;
+		n->vqs[i].coalesce_usecs = 0;
+		n->vqs[i].last_signal = ktime_get();
+		n->vqs[i].coalesced = 0;
+		hrtimer_init(&n->vqs[i].c_timer, CLOCK_MONOTONIC,
+			     HRTIMER_MODE_REL);
+		n->vqs[i].c_timer.function = vhost_net_timer_handler;
 	}
 	vhost_dev_init(dev, vqs, VHOST_NET_VQ_MAX);
 
@@ -907,6 +1016,7 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
 	struct vhost_virtqueue *vq;
 	struct vhost_net_virtqueue *nvq;
 	struct vhost_net_ubuf_ref *ubufs, *oldubufs = NULL;
+	unsigned int coalesced;
 	int r;
 
 	mutex_lock(&n->dev.mutex);
@@ -935,6 +1045,7 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
 
 	/* start polling new socket */
 	oldsock = vq->private_data;
+	coalesced = nvq->coalesced;
 	if (sock != oldsock) {
 		ubufs = vhost_net_ubuf_alloc(vq,
 					     sock && vhost_sock_zcopy(sock));
@@ -969,6 +1080,12 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
 		mutex_unlock(&vq->mutex);
 	}
 
+	if (coalesced) {
+		mutex_lock(&vq->mutex);
+		vhost_signal(&n->dev, vq);
+		mutex_unlock(&vq->mutex);
+	}
+
 	if (oldsock) {
 		vhost_net_flush_vq(n, index);
 		sockfd_put(oldsock);
@@ -1075,6 +1192,67 @@ out:
 	return r;
 }
 
+static long vhost_net_set_vring_coalesce(struct vhost_dev *d, void __user *argp)
+{
+	u32 __user *idxp = argp;
+	u32 idx;
+	int r;
+	struct vhost_virtqueue *vq;
+	struct vhost_net_vring_coalesce c;
+	struct vhost_net_virtqueue *nvq;
+
+	r = get_user(idx, idxp);
+	if (r < 0)
+		return r;
+	if (idx >= d->nvqs)
+		return -ENOBUFS;
+
+	vq = d->vqs[idx];
+	nvq = container_of(vq, struct vhost_net_virtqueue, vq);
+
+	r = copy_from_user(&c, argp, sizeof(c));
+	if (r < 0)
+		return r;
+
+	mutex_lock(&vq->mutex);
+	nvq->coalesce_usecs = c.coalesce_usecs;
+	nvq->max_coalesced_frames = c.max_coalesced_frames;
+	mutex_unlock(&vq->mutex);
+
+	return 0;
+}
+
+static long vhost_net_get_vring_coalesce(struct vhost_dev *d, void __user *argp)
+{
+	u32 __user *idxp = argp;
+	u32 idx;
+	int r;
+	struct vhost_virtqueue *vq;
+	struct vhost_net_vring_coalesce c;
+	struct vhost_net_virtqueue *nvq;
+
+	r = get_user(idx, idxp);
+	if (r < 0)
+		return r;
+	if (idx >= d->nvqs)
+		return -ENOBUFS;
+
+	vq = d->vqs[idx];
+	nvq = container_of(vq, struct vhost_net_virtqueue, vq);
+
+	mutex_lock(&vq->mutex);
+	c.index = idx;
+	c.coalesce_usecs = nvq->coalesce_usecs;
+	c.max_coalesced_frames = nvq->max_coalesced_frames;
+	mutex_unlock(&vq->mutex);
+
+	r = copy_to_user(argp, &c, sizeof(c));
+	if (r < 0)
+		return r;
+
+	return 0;
+}
+
 static long vhost_net_ioctl(struct file *f, unsigned int ioctl,
 			    unsigned long arg)
 {
@@ -1105,6 +1283,10 @@ static long vhost_net_ioctl(struct file *f, unsigned int ioctl,
 		return vhost_net_reset_owner(n);
 	case VHOST_SET_OWNER:
 		return vhost_net_set_owner(n);
+	case VHOST_NET_SET_VRING_COALESCE:
+		return vhost_net_set_vring_coalesce(&n->dev, argp);
+	case VHOST_NET_GET_VRING_COALESCE:
+		return vhost_net_get_vring_coalesce(&n->dev, argp);
 	default:
 		mutex_lock(&n->dev.mutex);
 		r = vhost_dev_ioctl(&n->dev, ioctl, argp);
diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
index bb6a5b4..6799cc1 100644
--- a/include/uapi/linux/vhost.h
+++ b/include/uapi/linux/vhost.h
@@ -27,6 +27,12 @@ struct vhost_vring_file {
 
 };
 
+struct vhost_net_vring_coalesce {
+	unsigned int index;
+	__u32 coalesce_usecs;
+	__u32 max_coalesced_frames;
+};
+
 struct vhost_vring_addr {
 	unsigned int index;
 	/* Option flags. */
@@ -121,6 +127,12 @@ struct vhost_memory {
  * device.  This can be used to stop the ring (e.g. for migration). */
 #define VHOST_NET_SET_BACKEND _IOW(VHOST_VIRTIO, 0x30, struct vhost_vring_file)
 
+/* Setting interrupt coalescing parameters. */
+#define VHOST_NET_SET_VRING_COALESCE \
+	_IOW(VHOST_VIRTIO, 0x31, struct vhost_net_vring_coalesce)
+/* Getting interrupt coalescing parameters. */
+#define VHOST_NET_GET_VRING_COALESCE \
+	_IOW(VHOST_VIRTIO, 0x32, struct vhost_net_vring_coalesce)
 /* Feature bits */
 /* Log all write descriptors. Can be changed while device is active. */
 #define VHOST_F_LOG_ALL 26
-- 
1.8.3.1

^ permalink raw reply related

* [PATCH RFC v4 net-next 4/5] virtio-net: add basic interrupt coalescing support
From: Jason Wang @ 2014-12-01 10:17 UTC (permalink / raw)
  To: mst, virtualization, netdev, linux-kernel, davem; +Cc: pagupta
In-Reply-To: <1417429028-11971-1-git-send-email-jasowang@redhat.com>

This patch enables the interrupt coalescing setting through ethtool.

Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/net/virtio_net.c        | 67 +++++++++++++++++++++++++++++++++++++++++
 include/uapi/linux/virtio_net.h | 12 ++++++++
 2 files changed, 79 insertions(+)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 9f420c9..2a3551a 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -142,6 +142,11 @@ struct virtnet_info {
 
 	/* Budget for polling tx completion */
 	u32 tx_work_limit;
+
+	__u32 rx_coalesce_usecs;
+	__u32 rx_max_coalesced_frames;
+	__u32 tx_coalesce_usecs;
+	__u32 tx_max_coalesced_frames;
 };
 
 struct skb_vnet_hdr {
@@ -1419,12 +1424,73 @@ static void virtnet_get_channels(struct net_device *dev,
 	channels->other_count = 0;
 }
 
+static int virtnet_set_coalesce(struct net_device *dev,
+				struct ethtool_coalesce *ec)
+{
+	struct virtnet_info *vi = netdev_priv(dev);
+	struct scatterlist sg;
+	struct virtio_net_ctrl_coalesce c;
+
+	if (!vi->has_cvq ||
+	    !virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_COALESCE))
+		return -EOPNOTSUPP;
+	if (vi->rx_coalesce_usecs != ec->rx_coalesce_usecs ||
+	    vi->rx_max_coalesced_frames != ec->rx_max_coalesced_frames) {
+		c.coalesce_usecs = ec->rx_coalesce_usecs;
+		c.max_coalesced_frames = ec->rx_max_coalesced_frames;
+		sg_init_one(&sg, &c, sizeof(c));
+		if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_COALESCE,
+					  VIRTIO_NET_CTRL_COALESCE_RX_SET,
+					  &sg)) {
+			dev_warn(&dev->dev, "Fail to set rx coalescing\n");
+			return -EINVAL;
+		}
+		vi->rx_coalesce_usecs = ec->rx_coalesce_usecs;
+		vi->rx_max_coalesced_frames = ec->rx_max_coalesced_frames;
+	}
+
+	if (vi->tx_coalesce_usecs != ec->tx_coalesce_usecs ||
+	    vi->tx_max_coalesced_frames != ec->tx_max_coalesced_frames) {
+		c.coalesce_usecs = ec->tx_coalesce_usecs;
+		c.max_coalesced_frames = ec->tx_max_coalesced_frames;
+		sg_init_one(&sg, &c, sizeof(c));
+		if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_COALESCE,
+					  VIRTIO_NET_CTRL_COALESCE_TX_SET,
+					  &sg)) {
+			dev_warn(&dev->dev, "Fail to set tx coalescing\n");
+			return -EINVAL;
+		}
+		vi->tx_coalesce_usecs = ec->tx_coalesce_usecs;
+		vi->tx_max_coalesced_frames = ec->tx_max_coalesced_frames;
+	}
+
+	vi->tx_work_limit = ec->tx_max_coalesced_frames_irq;
+
+	return 0;
+}
+
+static int virtnet_get_coalesce(struct net_device *dev,
+				struct ethtool_coalesce *ec)
+{
+	struct virtnet_info *vi = netdev_priv(dev);
+
+	ec->rx_coalesce_usecs = vi->rx_coalesce_usecs;
+	ec->rx_max_coalesced_frames = vi->rx_max_coalesced_frames;
+	ec->tx_coalesce_usecs = vi->tx_coalesce_usecs;
+	ec->tx_max_coalesced_frames = vi->tx_max_coalesced_frames;
+	ec->tx_max_coalesced_frames_irq = vi->tx_work_limit;
+
+	return 0;
+}
+
 static const struct ethtool_ops virtnet_ethtool_ops = {
 	.get_drvinfo = virtnet_get_drvinfo,
 	.get_link = ethtool_op_get_link,
 	.get_ringparam = virtnet_get_ringparam,
 	.set_channels = virtnet_set_channels,
 	.get_channels = virtnet_get_channels,
+	.set_coalesce = virtnet_set_coalesce,
+	.get_coalesce = virtnet_get_coalesce,
 };
 
 #define MIN_MTU 68
@@ -2022,6 +2088,7 @@ static unsigned int features[] = {
 	VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ,
 	VIRTIO_NET_F_CTRL_MAC_ADDR,
 	VIRTIO_F_ANY_LAYOUT,
+	VIRTIO_NET_F_CTRL_COALESCE,
 };
 
 static struct virtio_driver virtio_net_driver = {
diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h
index 172a7f0..cdafb57 100644
--- a/include/uapi/linux/virtio_net.h
+++ b/include/uapi/linux/virtio_net.h
@@ -33,6 +33,7 @@
 /* The feature bitmap for virtio net */
 #define VIRTIO_NET_F_CSUM	0	/* Host handles pkts w/ partial csum */
 #define VIRTIO_NET_F_GUEST_CSUM	1	/* Guest handles pkts w/ partial csum */
+#define VIRTIO_NET_F_CTRL_COALESCE 3	/* Set coalescing */
 #define VIRTIO_NET_F_MAC	5	/* Host has given MAC address. */
 #define VIRTIO_NET_F_GSO	6	/* Host handles pkts w/ any GSO type */
 #define VIRTIO_NET_F_GUEST_TSO4	7	/* Guest can handle TSOv4 in. */
@@ -201,4 +202,15 @@ struct virtio_net_ctrl_mq {
  #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN        1
  #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX        0x8000
 
+struct virtio_net_ctrl_coalesce {
+	__u32 coalesce_usecs;
+	__u32 max_coalesced_frames;
+};
+
+#define VIRTIO_NET_CTRL_COALESCE 6
+ #define VIRTIO_NET_CTRL_COALESCE_TX_SET 0
+ #define VIRTIO_NET_CTRL_COALESCE_TX_GET 1
+ #define VIRTIO_NET_CTRL_COALESCE_RX_SET 2
+ #define VIRTIO_NET_CTRL_COALESCE_RX_GET 3
+
 #endif /* _LINUX_VIRTIO_NET_H */
-- 
1.8.3.1

^ permalink raw reply related

* [PATCH RFC v4 net-next 3/5] virtio-net: optimize free_old_xmit_skbs stats
From: Jason Wang @ 2014-12-01 10:17 UTC (permalink / raw)
  To: mst, virtualization, netdev, linux-kernel, davem; +Cc: pagupta
In-Reply-To: <1417429028-11971-1-git-send-email-jasowang@redhat.com>

We already have counters for sent packets and sent bytes.
Use them to reduce the number of u64_stats_update_begin/end().

Take care not to bother with stats update when called
speculatively.

Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 drivers/net/virtio_net.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 0ed24ff..9f420c9 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -230,16 +230,23 @@ static unsigned int free_old_xmit_skbs(struct netdev_queue *txq,
 	       (skb = virtqueue_get_buf(sq->vq, &len)) != NULL) {
 		pr_debug("Sent skb %p\n", skb);
 
-		u64_stats_update_begin(&stats->tx_syncp);
-		stats->tx_bytes += skb->len;
 		bytes += skb->len;
-		stats->tx_packets++;
-		u64_stats_update_end(&stats->tx_syncp);
+		packets++;
 
 		dev_kfree_skb_any(skb);
-		packets++;
 	}
 
+	/* Avoid overhead when no packets have been processed
+	 * happens when called speculatively from start_xmit.
+	 */
+	if (!packets)
+		return 0;
+
+	u64_stats_update_begin(&stats->tx_syncp);
+	stats->tx_bytes += bytes;
+	stats->tx_packets += packets;
+	u64_stats_update_end(&stats->tx_syncp);
+
 	netdev_tx_completed_queue(txq, packets, bytes);
 
 	if (sq->vq->num_free >= 2+MAX_SKB_FRAGS)
-- 
1.8.3.1

^ permalink raw reply related

* [PATCH RFC v4 net-next 2/5] virtio_net: bql
From: Jason Wang @ 2014-12-01 10:17 UTC (permalink / raw)
  To: mst, virtualization, netdev, linux-kernel, davem; +Cc: pagupta
In-Reply-To: <1417429028-11971-1-git-send-email-jasowang@redhat.com>

From: "Michael S. Tsirkin" <mst@redhat.com>

Improve tx batching using byte queue limits.
Should be especially effective for MQ.

Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 drivers/net/virtio_net.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index f68114e..0ed24ff 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -224,6 +224,7 @@ static unsigned int free_old_xmit_skbs(struct netdev_queue *txq,
 	struct virtnet_info *vi = sq->vq->vdev->priv;
 	struct virtnet_stats *stats = this_cpu_ptr(vi->stats);
 	unsigned int packets = 0;
+	unsigned int bytes = 0;
 
 	while (packets < budget &&
 	       (skb = virtqueue_get_buf(sq->vq, &len)) != NULL) {
@@ -231,6 +232,7 @@ static unsigned int free_old_xmit_skbs(struct netdev_queue *txq,
 
 		u64_stats_update_begin(&stats->tx_syncp);
 		stats->tx_bytes += skb->len;
+		bytes += skb->len;
 		stats->tx_packets++;
 		u64_stats_update_end(&stats->tx_syncp);
 
@@ -238,6 +240,8 @@ static unsigned int free_old_xmit_skbs(struct netdev_queue *txq,
 		packets++;
 	}
 
+	netdev_tx_completed_queue(txq, packets, bytes);
+
 	if (sq->vq->num_free >= 2+MAX_SKB_FRAGS)
 		netif_tx_start_queue(txq);
 
@@ -964,6 +968,7 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
 	int err;
 	struct netdev_queue *txq = netdev_get_tx_queue(dev, qnum);
 	bool kick = !skb->xmit_more;
+	unsigned int bytes = skb->len;
 
 	virtqueue_disable_cb(sq->vq);
 
@@ -981,6 +986,8 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
 		return NETDEV_TX_OK;
 	}
 
+	netdev_tx_sent_queue(txq, bytes);
+
 	/* Apparently nice girls don't return TX_BUSY; stop the queue
 	 * before it gets out of hand.  Naturally, this wastes entries. */
 	if (sq->vq->num_free < 2+MAX_SKB_FRAGS)
-- 
1.8.3.1

^ permalink raw reply related

* [PATCH RFC v4 net-next 1/5] virtio_net: enable tx interrupt
From: Jason Wang @ 2014-12-01 10:17 UTC (permalink / raw)
  To: mst, virtualization, netdev, linux-kernel, davem; +Cc: pagupta
In-Reply-To: <1417429028-11971-1-git-send-email-jasowang@redhat.com>

On newer hosts that support delayed tx interrupts,
we probably don't have much to gain from orphaning
packets early.

Note: this might degrade performance for
hosts without event idx support.
Should be addressed by the next patch.

Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/net/virtio_net.c | 132 +++++++++++++++++++++++++++++++----------------
 1 file changed, 88 insertions(+), 44 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index ec2a8b4..f68114e 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -72,6 +72,8 @@ struct send_queue {
 
 	/* Name of the send queue: output.$index */
 	char name[40];
+
+	struct napi_struct napi;
 };
 
 /* Internal representation of a receive virtqueue */
@@ -137,6 +139,9 @@ struct virtnet_info {
 
 	/* CPU hot plug notifier */
 	struct notifier_block nb;
+
+	/* Budget for polling tx completion */
+	u32 tx_work_limit;
 };
 
 struct skb_vnet_hdr {
@@ -211,15 +216,41 @@ static struct page *get_a_page(struct receive_queue *rq, gfp_t gfp_mask)
 	return p;
 }
 
+static unsigned int free_old_xmit_skbs(struct netdev_queue *txq,
+				       struct send_queue *sq, int budget)
+{
+	struct sk_buff *skb;
+	unsigned int len;
+	struct virtnet_info *vi = sq->vq->vdev->priv;
+	struct virtnet_stats *stats = this_cpu_ptr(vi->stats);
+	unsigned int packets = 0;
+
+	while (packets < budget &&
+	       (skb = virtqueue_get_buf(sq->vq, &len)) != NULL) {
+		pr_debug("Sent skb %p\n", skb);
+
+		u64_stats_update_begin(&stats->tx_syncp);
+		stats->tx_bytes += skb->len;
+		stats->tx_packets++;
+		u64_stats_update_end(&stats->tx_syncp);
+
+		dev_kfree_skb_any(skb);
+		packets++;
+	}
+
+	if (sq->vq->num_free >= 2+MAX_SKB_FRAGS)
+		netif_tx_start_queue(txq);
+
+	return packets;
+}
+
 static void skb_xmit_done(struct virtqueue *vq)
 {
 	struct virtnet_info *vi = vq->vdev->priv;
+	struct send_queue *sq = &vi->sq[vq2txq(vq)];
 
-	/* Suppress further interrupts. */
-	virtqueue_disable_cb(vq);
-
-	/* We were probably waiting for more output buffers. */
-	netif_wake_subqueue(vi->dev, vq2txq(vq));
+	virtqueue_disable_cb(sq->vq);
+	napi_schedule(&sq->napi);
 }
 
 static unsigned int mergeable_ctx_to_buf_truesize(unsigned long mrg_ctx)
@@ -777,6 +808,32 @@ again:
 	return received;
 }
 
+static int virtnet_poll_tx(struct napi_struct *napi, int budget)
+{
+	struct send_queue *sq =
+		container_of(napi, struct send_queue, napi);
+	struct virtnet_info *vi = sq->vq->vdev->priv;
+	struct netdev_queue *txq = netdev_get_tx_queue(vi->dev, vq2txq(sq->vq));
+	u32 limit = vi->tx_work_limit;
+	unsigned int sent;
+
+	__netif_tx_lock(txq, smp_processor_id());
+	sent = free_old_xmit_skbs(txq, sq, limit);
+	if (sent < limit) {
+		napi_complete(napi);
+		/* Note: we must enable cb *after* napi_complete, because
+		 * napi_schedule calls from callbacks that trigger before
+		 * napi_complete are ignored.
+		 */
+		if (unlikely(!virtqueue_enable_cb_delayed(sq->vq))) {
+			virtqueue_disable_cb(sq->vq);
+			napi_schedule(&sq->napi);
+		}
+	}
+	__netif_tx_unlock(txq);
+	return sent < limit ? 0 : budget;
+}
+
 #ifdef CONFIG_NET_RX_BUSY_POLL
 /* must be called with local_bh_disable()d */
 static int virtnet_busy_poll(struct napi_struct *napi)
@@ -825,30 +882,12 @@ static int virtnet_open(struct net_device *dev)
 			if (!try_fill_recv(&vi->rq[i], GFP_KERNEL))
 				schedule_delayed_work(&vi->refill, 0);
 		virtnet_napi_enable(&vi->rq[i]);
+		napi_enable(&vi->sq[i].napi);
 	}
 
 	return 0;
 }
 
-static void free_old_xmit_skbs(struct send_queue *sq)
-{
-	struct sk_buff *skb;
-	unsigned int len;
-	struct virtnet_info *vi = sq->vq->vdev->priv;
-	struct virtnet_stats *stats = this_cpu_ptr(vi->stats);
-
-	while ((skb = virtqueue_get_buf(sq->vq, &len)) != NULL) {
-		pr_debug("Sent skb %p\n", skb);
-
-		u64_stats_update_begin(&stats->tx_syncp);
-		stats->tx_bytes += skb->len;
-		stats->tx_packets++;
-		u64_stats_update_end(&stats->tx_syncp);
-
-		dev_kfree_skb_any(skb);
-	}
-}
-
 static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)
 {
 	struct skb_vnet_hdr *hdr;
@@ -912,7 +951,9 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)
 		sg_set_buf(sq->sg, hdr, hdr_len);
 		num_sg = skb_to_sgvec(skb, sq->sg + 1, 0, skb->len) + 1;
 	}
-	return virtqueue_add_outbuf(sq->vq, sq->sg, num_sg, skb, GFP_ATOMIC);
+
+	return virtqueue_add_outbuf(sq->vq, sq->sg, num_sg, skb,
+				    GFP_ATOMIC);
 }
 
 static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
@@ -924,8 +965,7 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
 	struct netdev_queue *txq = netdev_get_tx_queue(dev, qnum);
 	bool kick = !skb->xmit_more;
 
-	/* Free up any pending old buffers before queueing new ones. */
-	free_old_xmit_skbs(sq);
+	virtqueue_disable_cb(sq->vq);
 
 	/* Try to transmit */
 	err = xmit_skb(sq, skb);
@@ -941,27 +981,19 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
 		return NETDEV_TX_OK;
 	}
 
-	/* Don't wait up for transmitted skbs to be freed. */
-	skb_orphan(skb);
-	nf_reset(skb);
-
 	/* Apparently nice girls don't return TX_BUSY; stop the queue
 	 * before it gets out of hand.  Naturally, this wastes entries. */
-	if (sq->vq->num_free < 2+MAX_SKB_FRAGS) {
+	if (sq->vq->num_free < 2+MAX_SKB_FRAGS)
 		netif_stop_subqueue(dev, qnum);
-		if (unlikely(!virtqueue_enable_cb_delayed(sq->vq))) {
-			/* More just got used, free them then recheck. */
-			free_old_xmit_skbs(sq);
-			if (sq->vq->num_free >= 2+MAX_SKB_FRAGS) {
-				netif_start_subqueue(dev, qnum);
-				virtqueue_disable_cb(sq->vq);
-			}
-		}
-	}
 
 	if (kick || netif_xmit_stopped(txq))
 		virtqueue_kick(sq->vq);
 
+	if (unlikely(!virtqueue_enable_cb_delayed(sq->vq))) {
+		virtqueue_disable_cb(sq->vq);
+		napi_schedule(&sq->napi);
+	}
+
 	return NETDEV_TX_OK;
 }
 
@@ -1138,8 +1170,10 @@ static int virtnet_close(struct net_device *dev)
 	/* Make sure refill_work doesn't re-enable napi! */
 	cancel_delayed_work_sync(&vi->refill);
 
-	for (i = 0; i < vi->max_queue_pairs; i++)
+	for (i = 0; i < vi->max_queue_pairs; i++) {
 		napi_disable(&vi->rq[i].napi);
+		napi_disable(&vi->sq[i].napi);
+	}
 
 	return 0;
 }
@@ -1452,8 +1486,10 @@ static void virtnet_free_queues(struct virtnet_info *vi)
 {
 	int i;
 
-	for (i = 0; i < vi->max_queue_pairs; i++)
+	for (i = 0; i < vi->max_queue_pairs; i++) {
 		netif_napi_del(&vi->rq[i].napi);
+		netif_napi_del(&vi->sq[i].napi);
+	}
 
 	kfree(vi->rq);
 	kfree(vi->sq);
@@ -1607,6 +1643,8 @@ static int virtnet_alloc_queues(struct virtnet_info *vi)
 		netif_napi_add(vi->dev, &vi->rq[i].napi, virtnet_poll,
 			       napi_weight);
 		napi_hash_add(&vi->rq[i].napi);
+		netif_napi_add(vi->dev, &vi->sq[i].napi, virtnet_poll_tx,
+			       napi_weight);
 
 		sg_init_table(vi->rq[i].sg, ARRAY_SIZE(vi->rq[i].sg));
 		ewma_init(&vi->rq[i].mrg_avg_pkt_len, 1, RECEIVE_AVG_WEIGHT);
@@ -1790,6 +1828,8 @@ static int virtnet_probe(struct virtio_device *vdev)
 	if (err)
 		goto free_stats;
 
+	vi->tx_work_limit = napi_weight;
+
 #ifdef CONFIG_SYSFS
 	if (vi->mergeable_rx_bufs)
 		dev->sysfs_rx_queue_group = &virtio_net_mrg_rx_group;
@@ -1904,8 +1944,10 @@ static int virtnet_freeze(struct virtio_device *vdev)
 	if (netif_running(vi->dev)) {
 		for (i = 0; i < vi->max_queue_pairs; i++) {
 			napi_disable(&vi->rq[i].napi);
+			napi_disable(&vi->sq[i].napi);
 			napi_hash_del(&vi->rq[i].napi);
 			netif_napi_del(&vi->rq[i].napi);
+			netif_napi_del(&vi->sq[i].napi);
 		}
 	}
 
@@ -1930,8 +1972,10 @@ static int virtnet_restore(struct virtio_device *vdev)
 			if (!try_fill_recv(&vi->rq[i], GFP_KERNEL))
 				schedule_delayed_work(&vi->refill, 0);
 
-		for (i = 0; i < vi->max_queue_pairs; i++)
+		for (i = 0; i < vi->max_queue_pairs; i++) {
 			virtnet_napi_enable(&vi->rq[i]);
+			napi_enable(&vi->sq[i].napi);
+		}
 	}
 
 	netif_device_attach(vi->dev);
-- 
1.8.3.1

^ permalink raw reply related

* [PATCH RFC v4 net-next 0/5] virtio_net: enabling tx interrupts
From: Jason Wang @ 2014-12-01 10:17 UTC (permalink / raw)
  To: mst, virtualization, netdev, linux-kernel, davem; +Cc: pagupta

Hello:

We used to orphan packets before transmission for virtio-net. This breaks
socket accounting and can lead serveral functions won't work, e.g:

- Byte Queue Limit depends on tx completion nofication to work.
- Packet Generator depends on tx completion nofication for the last
  transmitted packet to complete.
- TCP Small Queue depends on proper accounting of sk_wmem_alloc to work.

This series tries to solve the issue by enabling tx interrupts. To minize
the performance impacts of this, several optimizations were used:

- In guest side, virtqueue_enable_cb_delayed() was used to delay the tx
  interrupt untile 3/4 pending packets were sent.
- In host side, interrupt coalescing were used to reduce tx interrupts.

Performance test results[1] (tx-frames 16 tx-usecs 16) shows:

- For guest receiving. No obvious regression on throughput were
  noticed. More cpu utilization were noticed in few cases.
- For guest transmission. Very huge improvement on througput for small
  packet transmission were noticed. This is expected since TSQ and other
  optimization for small packet transmission work after tx interrupt. But
  will use more cpu for large packets.
- For TCP_RR, regression (10% on transaction rate and cpu utilization) were
  found. Tx interrupt won't help but cause overhead in this case. Using
  more aggressive coalescing parameters may help to reduce the regression.

Changes from RFC V3:
- Don't free tx packets in ndo_start_xmit()
- Add interrupt coalescing support for virtio-net
Changes from RFC v2:
- clean up code, address issues raised by Jason
Changes from RFC v1:
- address comments by Jason Wang, use delayed cb everywhere
- rebased Jason's patch on top of mine and include it (with some tweaks)

Please reivew. Comments were more than welcomed.

[1] Performance Test result:

Environment:
- Two Intel(R) Xeon(R) CPU E5620 @ 2.40GHz machines connected back to back
  with 82599ES cards.
- Both host and guest were net-next.git plus the patch
- Coalescing parameters for the card:
  Adaptive RX: off  TX: off
  rx-usecs: 1
  rx-frames: 0
  tx-usecs: 0
  tx-frames: 0
- Vhost_net was enabled and zerocopy was disabled
- Tests was done by netperf-2.6
- Guest has 2 vcpus with single queue virtio-net

Results:
- Numbers of square brackets are whose significance is grater than 95%

Guest RX:

size/sessions/+throughput/+cpu/+per_cpu_throughput/
64/1/+2.0326/[+6.2807%]/-3.9970%/
64/2/-0.2104%/[+3.2012%]/[-3.3058%]/
64/4/+1.5956%/+2.2451%/-0.6353%/
64/8/+1.1732%/+3.5123%/-2.2598%/
256/1/+3.7619%/[+5.8117%]/-1.9372%/
256/2/-0.0661%/[+3.2511%]/-3.2127%/
256/4/+1.1435%/[-8.1842%]/[+10.1591%]/
256/8/[+2.2447%]/[+6.2044%]/[-3.7283%]/
1024/1/+9.1479%/[+12.0997%]/[-2.6332%]/
1024/2/[-17.3341%]/[+0.0000%]/[-17.3341%]/
1024/4/[-0.6284%]/-1.0376%/+0.4135%/
1024/8/+1.1444%/-1.6069%/+2.7961%/
4096/1/+0.0401%/-0.5993%/+0.6433%/
4096/2/[-0.5894%]/-2.2071%/+1.6542%/
4096/4/[-0.5560%]/-1.4969%/+0.9553%/
4096/8/-0.3362%/+2.7086%/-2.9645%/
16384/1/-0.0285%/+0.7247%/-0.7478%/
16384/2/-0.5286%/+0.3287%/-0.8545%/
16384/4/-0.3297%/-2.0543%/+1.7608%/
16384/8/+1.0932%/+4.0253%/-2.8187%/
65535/1/+0.0003%/-0.1502%/+0.1508%/
65535/2/[-0.6065%]/+0.2309%/-0.8355%/
65535/4/[-0.6861%]/[+3.9451%]/[-4.4554%]/
65535/8/+1.8359%/+3.1590%/-1.2825%/

Guest RX:
size/sessions/+throughput/+cpu/+per_cpu_throughput/
64/1/[+65.0961%]/[-8.6807%]/[+80.7900%]/
64/2/[+6.0288%]/[-2.2823%]/[+8.5052%]/
64/4/[+5.9038%]/[-2.1834%]/[+8.2677%]/
64/8/[+5.4154%]/[-2.1804%]/[+7.7651%]/
256/1/[+184.6462%]/[+4.8906%]/[+171.3742%]/
256/2/[+46.0731%]/[-8.9626%]/[+60.4539%]/
256/4/[+45.8547%]/[-8.3027%]/[+59.0612%]/
256/8/[+45.3486%]/[-8.4024%]/[+58.6817%]/
1024/1/[+432.5372%]/[+3.9566%]/[+412.2689%]/
1024/2/[-1.4207%]/[-23.6426%]/[+29.1025%]/
1024/4/-0.1003%/[-13.6416%]/[+15.6804%]/
1024/8/[+0.2200%]/[+2.0634%]/[-1.8061%]/
4096/1/[+18.4835%]/[-46.1508%]/[+120.0283%]/
4096/2/+0.1770%/[-26.2780%]/[+35.8848%]/
4096/4/-0.1012%/-0.7353%/+0.6388%/
4096/8/-0.6091%/+1.4159%/-1.9968%/
16384/1/-0.0424%/[+11.9373%]/[-10.7021%]/
16384/2/+0.0482%/+2.4685%/-2.3620%/
16384/4/+0.0840%/[+5.3587%]/[-5.0064%]/
16384/8/+0.0048%/[+5.0176%]/[-4.7733%]/
65535/1/-0.0095%/[+10.9408%]/[-9.8705%]/
65535/2/+0.1515%/[+8.1709%]/[-7.4137%]/
65535/4/+0.0203%/[+5.4316%]/[-5.1325%]/
65535/8/+0.1427%/[+6.2753%]/[-5.7705%]/

size/sessions/+trans.rate/+cpu/+per_cpu_trans.rate/
64/1/+0.2346%/[+11.5080%]/[-10.1099%]/
64/25/[-10.7893%]/-0.5791%/[-10.2697%]/
64/50/[-11.5997%]/-0.3429%/[-11.2956%]/
256/1/+0.7219%/[+13.2374%]/[-11.0524%]/
256/25/-6.9567%/+0.8887%/[-7.7763%]/
256/50/[-4.8814%]/-0.0338%/[-4.8492%]/
4096/1/-1.6061%/-0.7561%/-0.8565%/
4096/25/[+2.2120%]/[+1.0839%]/+1.1161%/
4096/50/[+5.6180%]/[+3.2116%]/[+2.3315%]/

Jason Wang (4):
  virtio_net: enable tx interrupt
  virtio-net: optimize free_old_xmit_skbs stats
  virtio-net: add basic interrupt coalescing support
  vhost_net: interrupt coalescing support

Michael S. Tsirkin (1):
  virtio_net: bql

 drivers/net/virtio_net.c        | 211 ++++++++++++++++++++++++++++++++--------
 drivers/vhost/net.c             | 200 +++++++++++++++++++++++++++++++++++--
 include/uapi/linux/vhost.h      |  12 +++
 include/uapi/linux/virtio_net.h |  12 +++
 4 files changed, 383 insertions(+), 52 deletions(-)

-- 
1.8.3.1

^ permalink raw reply

* [PATCH net-next] test: bpf: expand DIV_KX to DIV_MOD_KX
From: Denis Kirjanov @ 2014-12-01 10:12 UTC (permalink / raw)
  To: netdev; +Cc: Denis Kirjanov, Alexei Starovoitov

Expand DIV_KX to use BPF_MOD operation in the
DIV_KX bpf 'classic' test.

CC: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
---
 lib/test_bpf.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index 3f167d2..80d78c5 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -124,7 +124,7 @@ static struct bpf_test tests[] = {
 		{ { 0, 0xfffffffd } }
 	},
 	{
-		"DIV_KX",
+		"DIV_MOD_KX",
 		.u.insns = {
 			BPF_STMT(BPF_LD | BPF_IMM, 8),
 			BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 2),
@@ -134,12 +134,18 @@ static struct bpf_test tests[] = {
 			BPF_STMT(BPF_MISC | BPF_TAX, 0),
 			BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff),
 			BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 0x70000000),
+			BPF_STMT(BPF_MISC | BPF_TAX, 0),
+			BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff),
+			BPF_STMT(BPF_ALU | BPF_MOD | BPF_X, 0),
+			BPF_STMT(BPF_MISC | BPF_TAX, 0),
+			BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff),
+			BPF_STMT(BPF_ALU | BPF_MOD | BPF_K, 0x70000000),
 			BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
 			BPF_STMT(BPF_RET | BPF_A, 0)
 		},
 		CLASSIC | FLAG_NO_DATA,
 		{ },
-		{ { 0, 0x40000001 } }
+		{ { 0, 0x20000000 } }
 	},
 	{
 		"AND_OR_LSH_K",
-- 
1.7.10.4

^ permalink raw reply related

* Re: [PATCH RFC v3 0/3] virtio_net: enabling tx interrupts
From: Jason Wang @ 2014-12-01 10:14 UTC (permalink / raw)
  To: Michael S. Tsirkin, linux-kernel, netdev
In-Reply-To: <1413787824-16130-1-git-send-email-mst@redhat.com>



On 10/20/2014 02:52 PM, Michael S. Tsirkin wrote:
> RFC patches to enable tx interrupts.
> This is to demonstrate how this can be done without
> core virtio changes, and to make sure I understand
> the new APIs correctly.
>
> Testing TBD, I was asked for a version for early testing.
>
> Applies on top of patch: "virtio_net: fix use after free"
> that I recently sent.
>
> Changes from v3:
> 	clean up code, address issues raised by Jason
> Changes from v1:
>          address comments by Jason Wang, use delayed cb everywhere
>          rebased Jason's patch on top of mine and include it (with some tweaks)
>
> Jason Wang (1):
>    virtio-net: optimize free_old_xmit_skbs stats
>
> Michael S. Tsirkin (2):
>    virtio_net: enable tx interrupt
>    virtio_net: bql
>
>   drivers/net/virtio_net.c | 144 +++++++++++++++++++++++++++++++++--------------
>   1 file changed, 101 insertions(+), 43 deletions(-)
>

I've run a full tests on this series and see huge regression when 
zerocopy is disabled. Looks like the reason is zerocopy could coalescing 
tx completion which greatly reduce the number of tx interrupts.

I will post RFC V4 shortly with interrupt coalescing support. In this 
version I remove the tx packet cleanup in ndo_start_xmit() since it may 
reduce the effects of interrupt coalescing.

^ permalink raw reply

* Re: [PATCH] mips: bpf: Fix broken BPF_MOD
From: Markos Chandras @ 2014-12-01 10:13 UTC (permalink / raw)
  To: Denis Kirjanov, netdev
In-Reply-To: <1417427822-12729-1-git-send-email-kda@linux-powerpc.org>

On 12/01/2014 09:57 AM, Denis Kirjanov wrote:
> Remove optimize_div() from BPF_MOD | BPF_K case
> since we don't know the dividend and fix the
> emit_mod() by reading the mod operation result from HI register
> 
> Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
> ---
>  arch/mips/net/bpf_jit.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/mips/net/bpf_jit.c b/arch/mips/net/bpf_jit.c
> index 9b55143..9fd6834 100644
> --- a/arch/mips/net/bpf_jit.c
> +++ b/arch/mips/net/bpf_jit.c
> @@ -426,7 +426,7 @@ static inline void emit_mod(unsigned int dst, unsigned int src,
>  		u32 *p = &ctx->target[ctx->idx];
>  		uasm_i_divu(&p, dst, src);
>  		p = &ctx->target[ctx->idx + 1];
> -		uasm_i_mflo(&p, dst);
> +		uasm_i_mfhi(&p, dst);

That looks correct.

>  	}
>  	ctx->idx += 2; /* 2 insts */
>  }
> @@ -971,7 +971,7 @@ load_ind:
>  			break;
>  		case BPF_ALU | BPF_MOD | BPF_K:
>  			/* A %= k */
> -			if (k == 1 || optimize_div(&k)) {
> +			if (k == 1) {
>  				ctx->flags |= SEEN_A;
>  				emit_jit_reg_move(r_A, r_zero, ctx);
>  			} else {
> 

That looks correct too. Thanks for fixing these.

Can you also CC stable for inclusion in >=3.16?

Reviewed-by: Markos Chandras <markos.chandras@imgtec.com>

-- 
markos

^ permalink raw reply

* [PATCH] mips: bpf: Fix broken BPF_MOD
From: Denis Kirjanov @ 2014-12-01  9:57 UTC (permalink / raw)
  To: netdev; +Cc: markos.chandras, Denis Kirjanov

Remove optimize_div() from BPF_MOD | BPF_K case
since we don't know the dividend and fix the
emit_mod() by reading the mod operation result from HI register

Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
---
 arch/mips/net/bpf_jit.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/mips/net/bpf_jit.c b/arch/mips/net/bpf_jit.c
index 9b55143..9fd6834 100644
--- a/arch/mips/net/bpf_jit.c
+++ b/arch/mips/net/bpf_jit.c
@@ -426,7 +426,7 @@ static inline void emit_mod(unsigned int dst, unsigned int src,
 		u32 *p = &ctx->target[ctx->idx];
 		uasm_i_divu(&p, dst, src);
 		p = &ctx->target[ctx->idx + 1];
-		uasm_i_mflo(&p, dst);
+		uasm_i_mfhi(&p, dst);
 	}
 	ctx->idx += 2; /* 2 insts */
 }
@@ -971,7 +971,7 @@ load_ind:
 			break;
 		case BPF_ALU | BPF_MOD | BPF_K:
 			/* A %= k */
-			if (k == 1 || optimize_div(&k)) {
+			if (k == 1) {
 				ctx->flags |= SEEN_A;
 				emit_jit_reg_move(r_A, r_zero, ctx);
 			} else {
-- 
1.7.10.4

^ permalink raw reply related

* Re: [PATCH] skge: Unmask interrupts in case of spurious interrupts
From: Mirko Lindner @ 2014-12-01  9:53 UTC (permalink / raw)
  To: Lino Sanfilippo; +Cc: stephen, netdev, linux-kernel
In-Reply-To: <1417348291-1302-1-git-send-email-LinoSanfilippo@gmx.de>

On 30/11/14 12:51, Lino Sanfilippo wrote:
> In case of a spurious interrupt dont forget to reenable the interrupts that
> have been masked by reading the interrupt source register.
> 
> Signed-off-by: Lino Sanfilippo <LinoSanfilippo@gmx.de>
> ---
>  drivers/net/ethernet/marvell/skge.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c
> index 264eab7..7173836 100644
> --- a/drivers/net/ethernet/marvell/skge.c
> +++ b/drivers/net/ethernet/marvell/skge.c
> @@ -3433,10 +3433,9 @@ static irqreturn_t skge_intr(int irq, void *dev_id)
>  
>  	if (status & IS_HW_ERR)
>  		skge_error_irq(hw);
> -
> +out:
>  	skge_write32(hw, B0_IMSK, hw->intr_mask);
>  	skge_read32(hw, B0_IMSK);
> -out:
>  	spin_unlock(&hw->hw_lock);
>  
>  	return IRQ_RETVAL(handled);
> 

Looks OK.

Acked-by: Mirko Lindner <mlindner@marvell.com>

^ permalink raw reply

* Re: [PATCH net] openvswitch: Fix flow mask validation.
From: Thomas Graf @ 2014-12-01  9:42 UTC (permalink / raw)
  To: Pravin B Shelar; +Cc: davem, netdev
In-Reply-To: <1417417457-1492-1-git-send-email-pshelar@nicira.com>

On 11/30/14 at 11:04pm, Pravin B Shelar wrote:
> Following patch fixes typo in the flow validation. This prevented
> installation of ARP and IPv6 flows.
> 
> Fixes: 19e7a3df72 ("openvswitch: Fix NDP flow mask validation")
> Signed-off-by: Pravin B Shelar <pshelar@nicira.com>

Reviewed-by: Thomas Graf <tgraf@suug.ch>

^ permalink raw reply

* Re: [PATCH V4 net-next] tun/macvtap: use consume_skb() instead of kfree_skb() when needed
From: Michael S. Tsirkin @ 2014-12-01  9:30 UTC (permalink / raw)
  To: Jason Wang; +Cc: davem, netdev, linux-kernel, Eric Dumazet
In-Reply-To: <1417423995-4765-1-git-send-email-jasowang@redhat.com>

On Mon, Dec 01, 2014 at 04:53:15PM +0800, Jason Wang wrote:
> To be more friendly with drop monitor, we should only call kfree_skb() when
> the packets were dropped and use consume_skb() in other cases.
> 
> Cc: Eric Dumazet <eric.dumazet@gmail.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> ---
> Changes from V3:
> - rebase to net-next.git
> Changes from V2:
> - use unlikely() when necessary
> Changes from V1:
> - check the return value of tun/macvtap_put_user()
> ---
>  drivers/net/macvtap.c | 5 ++++-
>  drivers/net/tun.c     | 5 ++++-
>  2 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
> index 22b4cf2..ba1e5db 100644
> --- a/drivers/net/macvtap.c
> +++ b/drivers/net/macvtap.c
> @@ -859,7 +859,10 @@ static ssize_t macvtap_do_read(struct macvtap_queue *q,
>  	}
>  	if (skb) {
>  		ret = macvtap_put_user(q, skb, to);
> -		kfree_skb(skb);
> +		if (unlikely(ret < 0))
> +			kfree_skb(skb);
> +		else
> +			consume_skb(skb);
>  	}
>  	if (!noblock)
>  		finish_wait(sk_sleep(&q->sk), &wait);
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 6d44da1..9c58286 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -1362,7 +1362,10 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
>  		return 0;
>  
>  	ret = tun_put_user(tun, tfile, skb, to);
> -	kfree_skb(skb);
> +	if (unlikely(ret < 0))
> +		kfree_skb(skb);
> +	else
> +		consume_skb(skb);
>  
>  	return ret;
>  }
> -- 
> 1.9.1

^ permalink raw reply

* Re: [PATCH v7 28/46] vhost: make features 64 bit
From: Michael S. Tsirkin @ 2014-12-01  9:19 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: thuth, Sergei Shtylyov, rusty, netdev, linux-kernel,
	virtualization, dahi, kvm, pbonzini, David Miller
In-Reply-To: <1417407157.7215.127.camel@decadent.org.uk>

On Mon, Dec 01, 2014 at 04:12:37AM +0000, Ben Hutchings wrote:
> On Sun, 2014-11-30 at 18:44 +0300, Sergei Shtylyov wrote:
> > Hello.
> > 
> > On 11/30/2014 6:11 PM, Michael S. Tsirkin wrote:
> > 
> > > We need to use bit 32 for virtio 1.0
> > 
> > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > > Reviewed-by: Jason Wang <jasowang@redhat.com>
> > > ---
> > >   drivers/vhost/vhost.h | 4 ++--
> > >   1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > > diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
> > > index 3eda654..c624b09 100644
> > > --- a/drivers/vhost/vhost.h
> > > +++ b/drivers/vhost/vhost.h
> > > @@ -106,7 +106,7 @@ struct vhost_virtqueue {
> > >   	/* Protected by virtqueue mutex. */
> > >   	struct vhost_memory *memory;
> > >   	void *private_data;
> > > -	unsigned acked_features;
> > > +	u64 acked_features;
> > >   	/* Log write descriptors */
> > >   	void __user *log_base;
> > >   	struct vhost_log *log;
> > > @@ -174,6 +174,6 @@ enum {
> > >
> > >   static inline int vhost_has_feature(struct vhost_virtqueue *vq, int bit)
> > >   {
> > > -	return vq->acked_features & (1 << bit);
> > > +	return vq->acked_features & (1ULL << bit);
> > 
> >     Erm, wouldn't the high word be just dropped when returning *int*? I think 
> > you need !!(vq->acked_features & (1ULL << bit)).
> 
> Or change the return type to bool.
> 
> Ben.
> 
> -- 
> Ben Hutchings
> The first rule of tautology club is the first rule of tautology club.



Yes, I'll do that I think.
Thanks!

^ permalink raw reply

* Re: [PATCH net-next] vhost: remove unnecessary forward declarations in vhost.h
From: Michael S. Tsirkin @ 2014-12-01  9:18 UTC (permalink / raw)
  To: Jason Wang; +Cc: netdev, linux-kernel, kvm, virtualization
In-Reply-To: <1417070481-10331-1-git-send-email-jasowang@redhat.com>

On Thu, Nov 27, 2014 at 02:41:21PM +0800, Jason Wang wrote:
> Signed-off-by: Jason Wang <jasowang@redhat.com>

Applied, thanks.

> ---
>  drivers/vhost/vhost.h | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
> index 3eda654..7d039ef 100644
> --- a/drivers/vhost/vhost.h
> +++ b/drivers/vhost/vhost.h
> @@ -12,8 +12,6 @@
>  #include <linux/virtio_ring.h>
>  #include <linux/atomic.h>
>  
> -struct vhost_device;
> -
>  struct vhost_work;
>  typedef void (*vhost_work_fn_t)(struct vhost_work *work);
>  
> @@ -54,8 +52,6 @@ struct vhost_log {
>  	u64 len;
>  };
>  
> -struct vhost_virtqueue;
> -
>  /* The virtqueue structure describes a queue attached to a device. */
>  struct vhost_virtqueue {
>  	struct vhost_dev *dev;
> -- 
> 1.9.1

^ permalink raw reply

* Re: [Xen-devel] [PATCH] xen-netfront: Fix handling packets on compound pages with skb_linearize
From: Stefan Bader @ 2014-12-01  8:55 UTC (permalink / raw)
  To: Zoltan Kiss, Konrad Rzeszutek Wilk, Boris Ostrovsky, David Vrabel
  Cc: Wei Liu, Ian Campbell, netdev, linux-kernel, Paul Durrant,
	xen-devel
In-Reply-To: <1407778343-13622-1-git-send-email-zoltan.kiss@citrix.com>

[-- Attachment #1: Type: text/plain, Size: 2926 bytes --]

On 11.08.2014 19:32, Zoltan Kiss wrote:
> There is a long known problem with the netfront/netback interface: if the guest
> tries to send a packet which constitues more than MAX_SKB_FRAGS + 1 ring slots,
> it gets dropped. The reason is that netback maps these slots to a frag in the
> frags array, which is limited by size. Having so many slots can occur since
> compound pages were introduced, as the ring protocol slice them up into
> individual (non-compound) page aligned slots. The theoretical worst case
> scenario looks like this (note, skbs are limited to 64 Kb here):
> linear buffer: at most PAGE_SIZE - 17 * 2 bytes, overlapping page boundary,
> using 2 slots
> first 15 frags: 1 + PAGE_SIZE + 1 bytes long, first and last bytes are at the
> end and the beginning of a page, therefore they use 3 * 15 = 45 slots
> last 2 frags: 1 + 1 bytes, overlapping page boundary, 2 * 2 = 4 slots
> Although I don't think this 51 slots skb can really happen, we need a solution
> which can deal with every scenario. In real life there is only a few slots
> overdue, but usually it causes the TCP stream to be blocked, as the retry will
> most likely have the same buffer layout.
> This patch solves this problem by linearizing the packet. This is not the
> fastest way, and it can fail much easier as it tries to allocate a big linear
> area for the whole packet, but probably easier by an order of magnitude than
> anything else. Probably this code path is not touched very frequently anyway.
> 
> Signed-off-by: Zoltan Kiss <zoltan.kiss@citrix.com>
> Cc: Wei Liu <wei.liu2@citrix.com>
> Cc: Ian Campbell <Ian.Campbell@citrix.com>
> Cc: Paul Durrant <paul.durrant@citrix.com>
> Cc: netdev@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: xen-devel@lists.xenproject.org

This does not seem to be marked explicitly as stable. Has someone already asked
David Miller to put it on his stable queue? IMO it qualifies quite well and the
actual change should be simple to pick/backport.

-Stefan

> 
> diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
> index 055222b..23359ae 100644
> --- a/drivers/net/xen-netfront.c
> +++ b/drivers/net/xen-netfront.c
> @@ -628,9 +628,10 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
>  	slots = DIV_ROUND_UP(offset + len, PAGE_SIZE) +
>  		xennet_count_skb_frag_slots(skb);
>  	if (unlikely(slots > MAX_SKB_FRAGS + 1)) {
> -		net_alert_ratelimited(
> -			"xennet: skb rides the rocket: %d slots\n", slots);
> -		goto drop;
> +		net_dbg_ratelimited("xennet: skb rides the rocket: %d slots, %d bytes\n",
> +				    slots, skb->len);
> +		if (skb_linearize(skb))
> +			goto drop;
>  	}
>  
>  	spin_lock_irqsave(&queue->tx_lock, flags);
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply

* [PATCH V4 net-next] tun/macvtap: use consume_skb() instead of kfree_skb() when needed
From: Jason Wang @ 2014-12-01  8:53 UTC (permalink / raw)
  To: davem, netdev, linux-kernel; +Cc: mst, Jason Wang, Eric Dumazet

To be more friendly with drop monitor, we should only call kfree_skb() when
the packets were dropped and use consume_skb() in other cases.

Cc: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
Changes from V3:
- rebase to net-next.git
Changes from V2:
- use unlikely() when necessary
Changes from V1:
- check the return value of tun/macvtap_put_user()
---
 drivers/net/macvtap.c | 5 ++++-
 drivers/net/tun.c     | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 22b4cf2..ba1e5db 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -859,7 +859,10 @@ static ssize_t macvtap_do_read(struct macvtap_queue *q,
 	}
 	if (skb) {
 		ret = macvtap_put_user(q, skb, to);
-		kfree_skb(skb);
+		if (unlikely(ret < 0))
+			kfree_skb(skb);
+		else
+			consume_skb(skb);
 	}
 	if (!noblock)
 		finish_wait(sk_sleep(&q->sk), &wait);
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 6d44da1..9c58286 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1362,7 +1362,10 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
 		return 0;
 
 	ret = tun_put_user(tun, tfile, skb, to);
-	kfree_skb(skb);
+	if (unlikely(ret < 0))
+		kfree_skb(skb);
+	else
+		consume_skb(skb);
 
 	return ret;
 }
-- 
1.9.1

^ permalink raw reply related

* Re: [PATCH net-next 0/3] timestamping updates
From: Richard Cochran @ 2014-12-01  8:49 UTC (permalink / raw)
  To: Willem de Bruijn; +Cc: netdev, davem, luto
In-Reply-To: <1417404155-28607-1-git-send-email-willemb@google.com>

On Sun, Nov 30, 2014 at 10:22:32PM -0500, Willem de Bruijn wrote:
> From: Willem de Bruijn <willemb@google.com>
> 
> The main goal for this patchset is to allow correlating timestamps
> with the egress interface. Also introduce a warning, as discussed
> previously, and update the tests to verify the new feature.
> 
> Willem de Bruijn (3):
>   ipv4: warn once on passing AF_INET6 socket to ip_recv_error
>   net-timestamp: allow reading recv cmsg on errqueue with origin tstamp
>   net-timestamp: expand documentation and test

Acked-by: Richard Cochran <richardcochran@gmail.com>

^ permalink raw reply

* Re: linux-next: manual merge of the driver-core tree with the net-next tree
From: Arend van Spriel @ 2014-12-01  7:34 UTC (permalink / raw)
  To: Stephen Rothwell, Greg KH, John W. Linville, David Miller, netdev
  Cc: linux-next, linux-kernel, Felix Fietkau, Ben Greear
In-Reply-To: <20141201181933.6dfaad66@canb.auug.org.au>

On 01-12-14 08:19, Stephen Rothwell wrote:
> Hi Greg,
> 
> Today's linux-next merge of the driver-core tree got a conflict in
> drivers/net/wireless/ath/ath9k/debug.c between commits 70e535ed0029
> ("ath9k: clean up debugfs print of reset causes"), 7b8aaead958e
> ("ath9k: restart hardware after noise floor calibration failure") and
> 325e18817668 ("ath9k: fix misc debugfs when not using chan context")
> from the net-next tree and commit 631bee257bd5 ("ath: use seq_file api
> for ath9k debugfs files") from the driver-core tree.
> 
> I fixed it up (see below) and can carry the fix as necessary (no action
> is required).
> 
> Greg, I am not sure why those 2 commits are even in your tree.  Do they
> depend on something else in your tree?

They do. The three commits below are related:

d32394f ath: ath9k: use debugfs_create_devm_seqfile() helper for
seq_file entrie
631bee2 ath: use seq_file api for ath9k debugfs files
98210b7 debugfs: add helper function to create device related seq_file

The ath patches were made to provide example of using the new helper
function and get some idea about code savings. Greg and John discussed
who would take them. I noticed other ath changes in net-next so I kinda
expected this email ;-)

Regards,
Arend

^ permalink raw reply

* linux-next: manual merge of the driver-core tree with the net-next tree
From: Stephen Rothwell @ 2014-12-01  7:19 UTC (permalink / raw)
  To: Greg KH, John W. Linville, David Miller, netdev
  Cc: linux-next, linux-kernel, Arend van Spriel, Felix Fietkau,
	Ben Greear

[-- Attachment #1: Type: text/plain, Size: 5787 bytes --]

Hi Greg,

Today's linux-next merge of the driver-core tree got a conflict in
drivers/net/wireless/ath/ath9k/debug.c between commits 70e535ed0029
("ath9k: clean up debugfs print of reset causes"), 7b8aaead958e
("ath9k: restart hardware after noise floor calibration failure") and
325e18817668 ("ath9k: fix misc debugfs when not using chan context")
from the net-next tree and commit 631bee257bd5 ("ath: use seq_file api
for ath9k debugfs files") from the driver-core tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

Greg, I am not sure why those 2 commits are even in your tree.  Do they
depend on something else in your tree?

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au

diff --cc drivers/net/wireless/ath/ath9k/debug.c
index 696e3d5309c6,a1f1614a05c2..000000000000
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@@ -832,57 -731,42 +731,46 @@@ static int read_file_misc(struct seq_fi
  			continue;
  		ath9k_calculate_iter_data(sc, ctx, &iter_data);
  
- 		len += scnprintf(buf + len, sizeof(buf) - len,
- 			"VIFS: CTX %i(%i) AP: %i STA: %i MESH: %i WDS: %i",
- 			i++, (int)(ctx->assigned), iter_data.naps,
- 			iter_data.nstations,
- 			iter_data.nmeshes, iter_data.nwds);
- 		len += scnprintf(buf + len, sizeof(buf) - len,
- 			" ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n",
- 			iter_data.nadhocs, sc->cur_chan->nvifs, sc->nbcnvifs);
+ 		seq_printf(file,
 -			   "VIF-COUNTS: CTX %i AP: %i STA: %i MESH: %i WDS: %i",
 -			   i++, iter_data.naps, iter_data.nstations,
++			   "VIFS: CTX %i(%i) AP: %i STA: %i MESH: %i WDS: %i",
++			   i++, (int)(ctx->assigned), iter_data.naps,
++			   iter_data.nstations,
+ 			   iter_data.nmeshes, iter_data.nwds);
+ 		seq_printf(file, " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n",
+ 			   iter_data.nadhocs, sc->cur_chan->nvifs,
+ 			   sc->nbcnvifs);
  	}
  
- 	if (len > sizeof(buf))
- 		len = sizeof(buf);
- 
- 	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
- 	return retval;
+ 	return 0;
  }
  
- static ssize_t read_file_reset(struct file *file, char __user *user_buf,
- 			       size_t count, loff_t *ppos)
+ static int read_file_reset(struct seq_file *file, void *data)
  {
- 	struct ath_softc *sc = file->private_data;
+ 	struct ath_softc *sc = dev_get_drvdata(file->private);
 +	static const char * const reset_cause[__RESET_TYPE_MAX] = {
 +		[RESET_TYPE_BB_HANG] = "Baseband Hang",
 +		[RESET_TYPE_BB_WATCHDOG] = "Baseband Watchdog",
 +		[RESET_TYPE_FATAL_INT] = "Fatal HW Error",
 +		[RESET_TYPE_TX_ERROR] = "TX HW error",
 +		[RESET_TYPE_TX_GTT] = "Transmit timeout",
 +		[RESET_TYPE_TX_HANG] = "TX Path Hang",
 +		[RESET_TYPE_PLL_HANG] = "PLL RX Hang",
 +		[RESET_TYPE_MAC_HANG] = "MAC Hang",
 +		[RESET_TYPE_BEACON_STUCK] = "Stuck Beacon",
 +		[RESET_TYPE_MCI] = "MCI Reset",
 +		[RESET_TYPE_CALIBRATION] = "Calibration error",
 +	};
- 	char buf[512];
- 	unsigned int len = 0;
 +	int i;
  
 -	seq_printf(file, "%17s: %2d\n", "Baseband Hang",
 -		   sc->debug.stats.reset[RESET_TYPE_BB_HANG]);
 -	seq_printf(file, "%17s: %2d\n", "Baseband Watchdog",
 -		   sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG]);
 -	seq_printf(file, "%17s: %2d\n", "Fatal HW Error",
 -		   sc->debug.stats.reset[RESET_TYPE_FATAL_INT]);
 -	seq_printf(file, "%17s: %2d\n", "TX HW error",
 -		   sc->debug.stats.reset[RESET_TYPE_TX_ERROR]);
 -	seq_printf(file, "%17s: %2d\n", "TX Path Hang",
 -		   sc->debug.stats.reset[RESET_TYPE_TX_HANG]);
 -	seq_printf(file, "%17s: %2d\n", "PLL RX Hang",
 -		   sc->debug.stats.reset[RESET_TYPE_PLL_HANG]);
 -	seq_printf(file, "%17s: %2d\n", "MAC Hang",
 -		   sc->debug.stats.reset[RESET_TYPE_MAC_HANG]);
 -	seq_printf(file, "%17s: %2d\n", "Stuck Beacon",
 -		   sc->debug.stats.reset[RESET_TYPE_BEACON_STUCK]);
 -	seq_printf(file, "%17s: %2d\n", "MCI Reset",
 -		   sc->debug.stats.reset[RESET_TYPE_MCI]);
 +	for (i = 0; i < ARRAY_SIZE(reset_cause); i++) {
 +		if (!reset_cause[i])
 +		    continue;
 +
- 		len += scnprintf(buf + len, sizeof(buf) - len,
- 				 "%17s: %2d\n", reset_cause[i],
- 				 sc->debug.stats.reset[i]);
++		seq_printf(file, "%17s: %2d\n", reset_cause[i],
++			   sc->debug.stats.reset[i]);
 +	}
  
- 	if (len > sizeof(buf))
- 		len = sizeof(buf);
- 
- 	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+ 	return 0;
  }
  
  void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
@@@ -1331,16 -1175,16 +1179,16 @@@ int ath9k_init_debug(struct ath_hw *ah
  
  	ath9k_dfs_init_debug(sc);
  	ath9k_tx99_init_debug(sc);
 -	ath9k_spectral_init_debug(sc);
 +	ath9k_cmn_spectral_init_debug(&sc->spec_priv, sc->debug.debugfs_phy);
  
- 	debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
- 			    &fops_dma);
- 	debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc,
- 			    &fops_interrupt);
- 	debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc,
- 			    &fops_xmit);
- 	debugfs_create_file("queues", S_IRUSR, sc->debug.debugfs_phy, sc,
- 			    &fops_queues);
+ 	debugfs_create_devm_seqfile(sc->dev, "dma", sc->debug.debugfs_phy,
+ 				    read_file_dma);
+ 	debugfs_create_devm_seqfile(sc->dev, "interrupt", sc->debug.debugfs_phy,
+ 				    read_file_interrupt);
+ 	debugfs_create_devm_seqfile(sc->dev, "xmit", sc->debug.debugfs_phy,
+ 				    read_file_xmit);
+ 	debugfs_create_devm_seqfile(sc->dev, "queues", sc->debug.debugfs_phy,
+ 				    read_file_queues);
  	debugfs_create_u32("qlen_bk", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
  			   &sc->tx.txq_max_pending[IEEE80211_AC_BK]);
  	debugfs_create_u32("qlen_be", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox