Added iavf(4) that is based on OpenBSD's iavf(4) implementation

reviewed by msaitoh@n.o and knakahara@n.o
This commit is contained in:
yamaguchi 2020-09-08 10:05:47 +00:00
parent 8a99708f0f
commit f474b47c56
18 changed files with 5840 additions and 124 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.1700 2020/08/28 12:15:05 christos Exp $
# $NetBSD: mi,v 1.1701 2020/09/08 10:05:47 yamaguchi Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@ -1311,6 +1311,7 @@
./usr/share/man/cat4/i4btrc.0 man-obsolete obsolete
./usr/share/man/cat4/i915drm.0 man-sys-catman .cat
./usr/share/man/cat4/iavc.0 man-obsolete obsolete
./usr/share/man/cat4/iavf.0 man-sys-catman .cat
./usr/share/man/cat4/ibmcd.0 man-sys-catman .cat
./usr/share/man/cat4/ibmhawk.0 man-sys-catman .cat
./usr/share/man/cat4/ichlpcib.0 man-obsolete obsolete
@ -4496,6 +4497,7 @@
./usr/share/man/html4/i386/viac7temp.html man-sys-htmlman html
./usr/share/man/html4/i915drm.html man-sys-htmlman html
./usr/share/man/html4/iavc.html man-obsolete obsolete
./usr/share/man/html4/iavf.html man-sys-htmlman html
./usr/share/man/html4/ibmcd.html man-sys-htmlman html
./usr/share/man/html4/ibmhawk.html man-sys-htmlman html
./usr/share/man/html4/ichlpcib.html man-obsolete obsolete
@ -7513,6 +7515,7 @@
./usr/share/man/man4/i4btrc.4 man-obsolete obsolete
./usr/share/man/man4/i915drm.4 man-sys-man .man
./usr/share/man/man4/iavc.4 man-obsolete obsolete
./usr/share/man/man4/iavf.4 man-sys-man .man
./usr/share/man/man4/ibmcd.4 man-sys-man .man
./usr/share/man/man4/ibmhawk.4 man-sys-man .man
./usr/share/man/man4/ichlpcib.4 man-obsolete obsolete

View File

@ -1,4 +1,4 @@
# $NetBSD: md.amd64,v 1.88 2020/08/27 15:32:00 riastradh Exp $
# $NetBSD: md.amd64,v 1.89 2020/09/08 10:05:47 yamaguchi Exp $
#
./@MODULEDIR@/acpiacad modules-base-kernel kmod
./@MODULEDIR@/acpiacad/acpiacad.kmod modules-base-kernel kmod
@ -158,6 +158,8 @@
./@MODULEDIR@/i915drmkms/i915drmkms.kmod modules-base-kernel kmod
./@MODULEDIR@/ichsmb modules-base-kernel kmod
./@MODULEDIR@/ichsmb/ichsmb.kmod modules-base-kernel kmod
./@MODULEDIR@/if_iavf modules-base-kernel kmod
./@MODULEDIR@/if_iavf/if_iavf.kmod modules-base-kernel kmod
./@MODULEDIR@/if_ixl modules-base-kernel kmod
./@MODULEDIR@/if_ixl/if_ixl.kmod modules-base-kernel kmod
./@MODULEDIR@/imc modules-base-kernel kmod

View File

@ -1,7 +1,9 @@
# $NetBSD: md.evbarm,v 1.1 2020/03/11 08:31:08 skrll Exp $
# $NetBSD: md.evbarm,v 1.2 2020/09/08 10:05:47 yamaguchi Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
./@MODULEDIR@/if_iavf modules-base-kernel kmod
./@MODULEDIR@/if_iavf/if_iavf.kmod modules-base-kernel kmod
./@MODULEDIR@/if_ixl modules-base-kernel kmod
./@MODULEDIR@/if_ixl/if_ixl.kmod modules-base-kernel kmod
./@MODULEDIR@/ubsec modules-base-kernel kmod

View File

@ -1,4 +1,4 @@
# $NetBSD: md.i386,v 1.88 2020/08/27 15:32:00 riastradh Exp $
# $NetBSD: md.i386,v 1.89 2020/09/08 10:05:47 yamaguchi Exp $
#
./@MODULEDIR@/acpiacad modules-base-kernel kmod
./@MODULEDIR@/acpiacad/acpiacad.kmod modules-base-kernel kmod
@ -112,6 +112,8 @@
./@MODULEDIR@/i915drmkms/i915drmkms.kmod modules-base-kernel kmod
./@MODULEDIR@/ichsmb modules-base-kernel kmod
./@MODULEDIR@/ichsmb/ichsmb.kmod modules-base-kernel kmod
./@MODULEDIR@/if_iavf modules-base-kernel kmod
./@MODULEDIR@/if_iavf/if_iavf.kmod modules-base-kernel kmod
./@MODULEDIR@/if_ixl modules-base-kernel kmod
./@MODULEDIR@/if_ixl/if_ixl.kmod modules-base-kernel kmod
./@MODULEDIR@/imc modules-base-kernel kmod

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.707 2020/08/20 21:36:00 riastradh Exp $
# $NetBSD: Makefile,v 1.708 2020/09/08 10:05:47 yamaguchi Exp $
# @(#)Makefile 8.1 (Berkeley) 6/18/93
MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \
@ -29,9 +29,9 @@ MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \
glxtphy.4 gpib.4 gpio.4 gpioirq.4 gpiolock.4 gpiopps.4 gpiopwm.4 \
gpiosim.4 gre.4 gphyter.4 gsip.4 \
hdaudio.4 hifn.4 hme.4 hpacel.4 hpqlb.4 hptide.4 hythygtemp.4 \
ibmcd.4 ibmhawk.4 ichsmb.4 icmp.4 icp.4 icsphy.4 iee.4 ieee80211.4 \
ifmedia.4 igmafb.4 igphy.4 igsfb.4 iha.4 ihidev.4 ihphy.4 iic.4 ims.4 \
inet.4 ikphy.4 inphy.4 intersil7170.4 intro.4 \
iavf.4 ibmcd.4 ibmhawk.4 ichsmb.4 icmp.4 icp.4 icsphy.4 iee.4 \
ieee80211.4 ifmedia.4 igmafb.4 igphy.4 igsfb.4 iha.4 ihidev.4 \
ihphy.4 iic.4 ims.4 inet.4 ikphy.4 inphy.4 intersil7170.4 intro.4 \
ioasic.4 ioat.4 iop.4 iophy.4 iopsp.4 ip.4 ipgphy.4 ipmi.4 ipw.4 \
irmce.4 isp.4 ismt.4 isv.4 itesio.4 iteide.4 iwi.4 iwm.4 iwn.4 ixg.4 \
ixl.4 ixpide.4 ixv.4 \

63
share/man/man4/iavf.4 Normal file
View File

@ -0,0 +1,63 @@
.\" $NetBSD: iavf.4,v 1.1 2020/09/08 10:05:47 yamaguchi Exp $
.\"
.\" Copyright (c) 2020 Internet Initiative Japan, Inc.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd September 7, 2020
.Dt IAVF 4
.Os
.Sh NAME
.Nm iavf
.Nd Intel Ethernet Adaptive Virtual Function driver
.Sh SYNOPSIS
.Cd "iavf* at pci? dev ? function ?"
.Sh DESCRIPTION
The
.Nm
driver supports the SR-IOV Virtual Functions of Intel 700 series Ethernet
controller devices.
.Sh SEE ALSO
.Xr arp 4 ,
.Xr ifmedia 4 ,
.Xr pci 4 ,
.Xr ifconfig 8
.Sh History
The
.Nm
driver comes from
.Ox .
It first appeared in
.Nx 10.0 .
.Sh AUTHORS
The
.Nm
driver was written by
.An David Gwynne Aq Mt dlg@openbsd.org
and
.An Jonathan Matthew Aq Mt jmatthew@openbsd.org .
It was imported from
.Ox
into
.Nx

View File

@ -1,4 +1,4 @@
# $NetBSD: ALL,v 1.162 2020/08/26 16:03:41 riastradh Exp $
# $NetBSD: ALL,v 1.163 2020/09/08 10:05:47 yamaguchi Exp $
# From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
#
# ALL machine description file
@ -17,7 +17,7 @@ include "arch/amd64/conf/std.amd64"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
#ident "ALL-$Revision: 1.162 $"
#ident "ALL-$Revision: 1.163 $"
maxusers 64 # estimated number of users
@ -979,6 +979,7 @@ fxp* at pci? dev ? function ? # Intel EtherExpress PRO 10+/100B
gem* at pci? dev ? function ? # Apple GMAC and Sun ERI gigabit enet
gsip* at pci? dev ? function ? # NS83820 Gigabit Ethernet
hme* at pci? dev ? function ? # Sun Microelectronics STP2002-STQ
iavf* at pci? dev ? function ? # Intel Adaptive Virtual Function
ipw* at pci? dev ? function ? # Intel PRO/Wireless 2100
iwi* at pci? dev ? function ? # Intel PRO/Wireless 2200BG
iwm* at pci? dev ? function ? # Intel Wireless WiFi Link 7xxx

View File

@ -1,4 +1,4 @@
# $NetBSD: GENERIC,v 1.578 2020/08/30 11:16:17 dholland Exp $
# $NetBSD: GENERIC,v 1.579 2020/09/08 10:05:47 yamaguchi Exp $
#
# GENERIC machine description file
#
@ -22,7 +22,7 @@ include "arch/amd64/conf/std.amd64"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
#ident "GENERIC-$Revision: 1.578 $"
#ident "GENERIC-$Revision: 1.579 $"
maxusers 64 # estimated number of users
@ -811,6 +811,7 @@ fxp* at pci? dev ? function ? # Intel EtherExpress PRO 10+/100B
gem* at pci? dev ? function ? # Apple GMAC and Sun ERI gigabit enet
gsip* at pci? dev ? function ? # NS83820 Gigabit Ethernet
hme* at pci? dev ? function ? # Sun Microelectronics STP2002-STQ
iavf* at pci? dev ? function ? # Intel Adaptive Virtual Function
ipw* at pci? dev ? function ? # Intel PRO/Wireless 2100
iwi* at pci? dev ? function ? # Intel PRO/Wireless 2200BG
iwm* at pci? dev ? function ? # Intel Centrino 7260

View File

@ -1,4 +1,4 @@
# $NetBSD: ALL,v 1.495 2020/08/01 08:20:49 maxv Exp $
# $NetBSD: ALL,v 1.496 2020/09/08 10:05:47 yamaguchi Exp $
# From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
#
# ALL machine description file
@ -17,7 +17,7 @@ include "arch/i386/conf/std.i386"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
#ident "ALL-$Revision: 1.495 $"
#ident "ALL-$Revision: 1.496 $"
maxusers 64 # estimated number of users
@ -1062,6 +1062,7 @@ fxp* at pci? dev ? function ? # Intel EtherExpress PRO 10+/100B
gem* at pci? dev ? function ? # Apple GMAC and Sun ERI gigabit enet
gsip* at pci? dev ? function ? # NS83820 Gigabit Ethernet
hme* at pci? dev ? function ? # Sun Microelectronics STP2002-STQ
iavf* at pci? dev ? function ? # Intel Adaptive Virtual Function
ipw* at pci? dev ? function ? # Intel PRO/Wireless 2100
iwi* at pci? dev ? function ? # Intel PRO/Wireless 2200BG
iwm* at pci? dev ? function ? # Intel Wireless WiFi Link 7xxx

View File

@ -1,4 +1,4 @@
# $NetBSD: GENERIC,v 1.1231 2020/08/16 10:27:47 jdolecek Exp $
# $NetBSD: GENERIC,v 1.1232 2020/09/08 10:05:47 yamaguchi Exp $
#
# GENERIC machine description file
#
@ -22,7 +22,7 @@ include "arch/i386/conf/std.i386"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
#ident "GENERIC-$Revision: 1.1231 $"
#ident "GENERIC-$Revision: 1.1232 $"
maxusers 64 # estimated number of users
@ -983,6 +983,7 @@ ex* at pci? dev ? function ? # 3Com 3c90x[BC]
fxp* at pci? dev ? function ? # Intel EtherExpress PRO 10+/100B
gsip* at pci? dev ? function ? # NS83820 Gigabit Ethernet
hme* at pci? dev ? function ? # Sun Microelectronics STP2002-STQ
iavf* at pci? dev ? function ? # Intel Adaptive Virtual Function
ipw* at pci? dev ? function ? # Intel PRO/Wireless 2100
iwi* at pci? dev ? function ? # Intel PRO/Wireless 2200BG
iwm* at pci? dev ? function ? # Intel Wireless WiFi Link 7xxx

View File

@ -1,4 +1,4 @@
# $NetBSD: files.pci,v 1.430 2020/07/26 14:51:18 jdolecek Exp $
# $NetBSD: files.pci,v 1.431 2020/09/08 10:05:47 yamaguchi Exp $
#
# Config file and device description for machine-independent PCI code.
# Included by ports that need it. Requires that the SCSI files be
@ -1166,6 +1166,11 @@ defflag opt_if_ixl.h IXL_DEBUG
defparam opt_if_ixl.h IXL_STATS_INTERVAL_MSEC
IXL_QUEUE_NUM
# Intel Ethernet Adaptive Virtual Function
device iavf: ether, ifnet, arp
attach iavf at pci
file dev/pci/if_iavf.c iavf
# Intel XMM 7360 LTE modem
device wwanc {} : tty
attach wwanc at pci

5333
sys/dev/pci/if_iavf.c Normal file

File diff suppressed because it is too large Load Diff

238
sys/dev/pci/if_iavfvar.h Normal file
View File

@ -0,0 +1,238 @@
/* $NetBSD: if_iavfvar.h,v 1.1 2020/09/08 10:05:47 yamaguchi Exp $ */
/*
* Copyright (c) 2020 Internet Initiative Japan, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _DEV_PCI_IF_IAVFVAR_H_
#define _DEV_PCI_IF_IAVFVAR_H_
/* aq commands */
#define IAVF_AQ_OP_SEND_TO_PF 0x0801
#define IAVF_AQ_OP_MSG_FROM_PF 0x0802
#define IAVF_AQ_OP_SHUTDOWN 0x0803
/* virt channel messages */
#define IAVF_VC_OP_VERSION 1
#define IAVF_VC_OP_RESET_VF 2
#define IAVF_VC_OP_GET_VF_RESOURCES 3
#define IAVF_VC_OP_CONFIG_TX_QUEUE 4
#define IAVF_VC_OP_CONFIG_RX_QUEUE 5
#define IAVF_VC_OP_CONFIG_VSI_QUEUES 6
#define IAVF_VC_OP_CONFIG_IRQ_MAP 7
#define IAVF_VC_OP_ENABLE_QUEUES 8
#define IAVF_VC_OP_DISABLE_QUEUES 9
#define IAVF_VC_OP_ADD_ETH_ADDR 10
#define IAVF_VC_OP_DEL_ETH_ADDR 11
#define IAVF_VC_OP_ADD_VLAN 12
#define IAVF_VC_OP_DEL_VLAN 13
#define IAVF_VC_OP_CONFIG_PROMISC 14
#define IAVF_VC_OP_GET_STATS 15
#define IAVF_VC_OP_EVENT 17
#define IAVF_VC_OP_CONFIG_RSS_KEY 23
#define IAVF_VC_OP_CONFIG_RSS_LUT 24
#define IAVF_VC_OP_GET_RSS_HENA_CAPS 25
#define IAVF_VC_OP_SET_RSS_HENA 26
#define IAVF_VC_OP_ENABLE_VLAN_STRIP 27
#define IAVF_VC_OP_DISABLE_VLAN_STRIP 28
#define IAVF_VC_OP_REQUEST_QUEUES 29
/* virt channel response codes */
#define IAVF_VC_RC_SUCCESS 0
#define IAVF_VC_RC_ERR_PARAM -5
#define IAVF_VC_RC_ERR_OPCODE -38
#define IAVF_VC_RC_ERR_CQP_COMPL -39
#define IAVF_VC_RC_ERR_VF_ID -40
#define IAVF_VC_RC_ERR_NOT_SUP -64
/* virt channel events */
#define IAVF_VC_EVENT_LINK_CHANGE 1
#define IAVF_VC_EVENT_RESET_IMPENDING 2
#define IAVF_VC_EVENT_PF_DRIVER_CLOSE 3
/* virt channel offloads */
#define IAVF_VC_OFFLOAD_L2 0x00000001
#define IAVF_VC_OFFLOAD_IWARP 0x00000002
#define IAVF_VC_OFFLOAD_RSVD 0x00000004
#define IAVF_VC_OFFLOAD_RSS_AQ 0x00000008
#define IAVF_VC_OFFLOAD_RSS_REG 0x00000010
#define IAVF_VC_OFFLOAD_WB_ON_ITR 0x00000020
#define IAVF_VC_OFFLOAD_REQ_QUEUES 0x00000040
#define IAVF_VC_OFFLOAD_VLAN 0x00010000
#define IAVF_VC_OFFLOAD_RX_POLLING 0x00020000
#define IAVF_VC_OFFLOAD_RSS_PCTYPE_V2 0x00040000
#define IAVF_VC_OFFLOAD_RSS_PF 0x00080000
#define IAVF_VC_OFFLOAD_ENCAP 0x00100000
#define IAVF_VC_OFFLOAD_ENCAP_CSUM 0x00200000
#define IAVF_VC_OFFLOAD_RX_ENCAP_CSUM 0x00400000
#define IAVF_VC_OFFLOAD_FMT "\020" \
"\027RENCAP" "\026ENCAPC" "\025ENCAP" \
"\024RSSPF" "\023RSSV2" "\022RPOLL" \
"\021VLAN" "\007REQQ" "\006WB" \
"\005RSSREG" "\004RSSAQ" "\003RSVD" \
"\002IWARP" "\001L2"
struct iavf_aq_vc {
uint32_t iaq_vc_opcode;
uint32_t iaq_vc_retval;
} __packed;
struct iavf_vc_version_info {
uint32_t major;
uint32_t minor;
} __packed;
struct iavf_vc_vsi_resource {
uint16_t vsi_id;
uint16_t num_queue_pairs;
uint32_t vsi_type;
uint16_t qset_handle;
uint8_t default_mac[ETHER_ADDR_LEN];
} __packed;
struct iavf_vc_vf_resource {
uint16_t num_vsis;
uint16_t num_qp;
uint16_t max_vectors;
uint16_t max_mtu;
uint32_t offload_flags;
uint32_t rss_key_size;
uint32_t rss_lut_size;
struct iavf_vc_vsi_resource
vsi_res[1];
} __packed;
struct iavf_vc_vector_map {
uint16_t vsi_id;
uint16_t vector_id;
uint16_t rxq_map;
uint16_t txq_map;
uint16_t rxitr_idx;
uint16_t txitr_idx;
} __packed;
struct iavf_vc_irq_map_info {
uint16_t num_vectors;
struct iavf_vc_vector_map vecmap[1];
} __packed;
struct iavf_vc_txq_info {
uint16_t vsi_id;
uint16_t queue_id;
uint16_t ring_len;
uint16_t headwb_ena; /* deprecated */
uint64_t dma_ring_addr;
uint64_t dma_headwb_addr; /* deprecated */
} __packed;
struct iavf_vc_rxq_info {
uint16_t vsi_id;
uint16_t queue_id;
uint32_t ring_len;
uint16_t hdr_size;
uint16_t splithdr_ena;
uint32_t databuf_size;
uint32_t max_pkt_size;
uint32_t pad1;
uint64_t dma_ring_addr;
uint32_t rx_split_pos;
uint32_t pad2;
} __packed;
struct iavf_vc_queue_pair_info {
struct iavf_vc_txq_info txq;
struct iavf_vc_rxq_info rxq;
} __packed;
struct iavf_vc_queue_config_info {
uint16_t vsi_id;
uint16_t num_queue_pairs;
uint32_t pad;
struct iavf_vc_queue_pair_info qpair[1];
} __packed;
struct iavf_vc_queue_select {
uint16_t vsi_id;
uint16_t pad;
uint32_t rx_queues;
uint32_t tx_queues;
} __packed;
struct iavf_vc_promisc_info {
uint16_t vsi_id;
uint16_t flags;
#define IAVF_FLAG_VF_UNICAST_PROMISC 0x0001
#define IAVF_FLAG_VF_MULTICAST_PROMISC 0x0002
} __packed;
struct iavf_vc_eth_addr {
uint8_t addr[ETHER_ADDR_LEN];
uint8_t pad[2];
} __packed;
struct iavf_vc_eth_addr_list {
uint16_t vsi_id;
uint16_t num_elements;
struct iavf_vc_eth_addr list[1];
} __packed;
struct iavf_vc_pf_event {
uint32_t event;
uint32_t link_speed;
uint8_t link_status;
uint8_t pad[3];
uint32_t severity;
} __packed;
struct iavf_vc_vlan_filter {
uint16_t vsi_id;
uint16_t num_vlan_id;
uint16_t vlan_id[1];
} __packed;
struct iavf_vc_rss_key {
uint16_t vsi_id;
uint16_t key_len;
uint8_t key[1];
uint8_t pad[1];
} __packed;
struct iavf_vc_rss_lut {
uint16_t vsi_id;
uint16_t lut_entries;
uint8_t lut[1];
uint8_t pad[1];
}__packed;
#define IAVF_RSS_VSI_LUT_ENTRY_MASK 0x3F
struct iavf_vc_res_request {
uint16_t num_queue_pairs;
} __packed;
#define I40E_MAX_VF_QUEUES 16
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ixl.c,v 1.74 2020/08/19 09:22:05 yamaguchi Exp $ */
/* $NetBSD: if_ixl.c,v 1.75 2020/09/08 10:05:47 yamaguchi Exp $ */
/*
* Copyright (c) 2013-2015, Intel Corporation
@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ixl.c,v 1.74 2020/08/19 09:22:05 yamaguchi Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_ixl.c,v 1.75 2020/09/08 10:05:47 yamaguchi Exp $");
#ifdef _KERNEL_OPT
#include "opt_net_mpsafe.h"
@ -148,29 +148,7 @@ struct ixl_softc; /* defined */
#define I40E_INTR_NOTX_RX_MASK I40E_PFINT_ICR0_QUEUE_0_MASK
#define I40E_INTR_NOTX_TX_MASK I40E_PFINT_ICR0_QUEUE_1_MASK
#define BIT_ULL(a) (1ULL << (a))
#define IXL_RSS_HENA_DEFAULT_BASE \
(BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_UDP) | \
BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_TCP) | \
BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_SCTP) | \
BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_OTHER) | \
BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV4) | \
BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_UDP) | \
BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_TCP) | \
BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_SCTP) | \
BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_OTHER) | \
BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV6) | \
BIT_ULL(I40E_FILTER_PCTYPE_L2_PAYLOAD))
#define IXL_RSS_HENA_DEFAULT_XL710 IXL_RSS_HENA_DEFAULT_BASE
#define IXL_RSS_HENA_DEFAULT_X722 (IXL_RSS_HENA_DEFAULT_XL710 | \
BIT_ULL(I40E_FILTER_PCTYPE_NONF_UNICAST_IPV4_UDP) | \
BIT_ULL(I40E_FILTER_PCTYPE_NONF_MULTICAST_IPV4_UDP) | \
BIT_ULL(I40E_FILTER_PCTYPE_NONF_UNICAST_IPV6_UDP) | \
BIT_ULL(I40E_FILTER_PCTYPE_NONF_MULTICAST_IPV6_UDP) | \
BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_TCP_SYN_NO_ACK) | \
BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_TCP_SYN_NO_ACK))
#define I40E_HASH_LUT_SIZE_128 0
#define IXL_RSS_KEY_SIZE_REG 13
#define IXL_ICR0_CRIT_ERR_MASK \
(I40E_PFINT_ICR0_PCI_EXCEPTION_MASK | \
@ -251,30 +229,6 @@ struct ixl_speed_type {
uint64_t net_speed;
};
struct ixl_aq_buf {
SIMPLEQ_ENTRY(ixl_aq_buf)
aqb_entry;
void *aqb_data;
bus_dmamap_t aqb_map;
bus_dma_segment_t aqb_seg;
size_t aqb_size;
int aqb_nsegs;
};
SIMPLEQ_HEAD(ixl_aq_bufs, ixl_aq_buf);
struct ixl_dmamem {
bus_dmamap_t ixm_map;
bus_dma_segment_t ixm_seg;
int ixm_nsegs;
size_t ixm_size;
void *ixm_kva;
};
#define IXL_DMA_MAP(_ixm) ((_ixm)->ixm_map)
#define IXL_DMA_DVA(_ixm) ((_ixm)->ixm_map->dm_segs[0].ds_addr)
#define IXL_DMA_KVA(_ixm) ((void *)(_ixm)->ixm_kva)
#define IXL_DMA_LEN(_ixm) ((_ixm)->ixm_size)
struct ixl_hmc_entry {
uint64_t hmc_base;
uint32_t hmc_count;
@ -984,62 +938,6 @@ static const struct ixl_aq_regs ixl_pf_aq_regs = {
#define ixl_flush(_s) (void)ixl_rd((_s), I40E_GLGEN_STAT)
#define ixl_nqueues(_sc) (1 << ((_sc)->sc_nqueue_pairs - 1))
static inline uint32_t
ixl_dmamem_hi(struct ixl_dmamem *ixm)
{
uint32_t retval;
uint64_t val;
if (sizeof(IXL_DMA_DVA(ixm)) > 4) {
val = (intptr_t)IXL_DMA_DVA(ixm);
retval = (uint32_t)(val >> 32);
} else {
retval = 0;
}
return retval;
}
static inline uint32_t
ixl_dmamem_lo(struct ixl_dmamem *ixm)
{
return (uint32_t)IXL_DMA_DVA(ixm);
}
static inline void
ixl_aq_dva(struct ixl_aq_desc *iaq, bus_addr_t addr)
{
uint64_t val;
if (sizeof(addr) > 4) {
val = (intptr_t)addr;
iaq->iaq_param[2] = htole32(val >> 32);
} else {
iaq->iaq_param[2] = htole32(0);
}
iaq->iaq_param[3] = htole32(addr);
}
static inline unsigned int
ixl_rxr_unrefreshed(unsigned int prod, unsigned int cons, unsigned int ndescs)
{
unsigned int num;
if (prod < cons)
num = cons - prod;
else
num = (ndescs - prod) + cons;
if (__predict_true(num > 0)) {
/* device cannot receive packets if all descripter is filled */
num -= 1;
}
return num;
}
CFATTACH_DECL3_NEW(ixl, sizeof(struct ixl_softc),
ixl_match, ixl_attach, ixl_detach, NULL, NULL, NULL,
DVF_DETACH_SHUTDOWN);
@ -5151,7 +5049,7 @@ ixl_hmc(struct ixl_softc *sc)
e->hmc_count = regs[i].count;
reg = ixl_rd(sc, regs[i].objsiz);
e->hmc_size = BIT_ULL(0x3F & reg);
e->hmc_size = IXL_BIT_ULL(0x3F & reg);
e->hmc_base = size;
if ((e->hmc_size * 8) < regs[i].minsize) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ixlvar.h,v 1.6 2020/02/12 06:37:21 yamaguchi Exp $ */
/* $NetBSD: if_ixlvar.h,v 1.7 2020/09/08 10:05:47 yamaguchi Exp $ */
/*
* Copyright (c) 2019 Internet Initiative Japan, Inc.
@ -60,6 +60,32 @@ enum i40e_filter_pctype {
I40E_FILTER_PCTYPE_L2_PAYLOAD = 63,
};
#define IXL_BIT_ULL(a) (1ULL << (a))
#define IXL_RSS_HENA_DEFAULT_BASE \
(IXL_BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_UDP) | \
IXL_BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_TCP) | \
IXL_BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_SCTP) | \
IXL_BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_OTHER) | \
IXL_BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV4) | \
IXL_BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_UDP) | \
IXL_BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_TCP) | \
IXL_BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_SCTP) | \
IXL_BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_OTHER) | \
IXL_BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV6) | \
IXL_BIT_ULL(I40E_FILTER_PCTYPE_L2_PAYLOAD))
#define IXL_RSS_HENA_DEFAULT_XL710 IXL_RSS_HENA_DEFAULT_BASE
#define IXL_RSS_HENA_DEFAULT_X722 (IXL_RSS_HENA_DEFAULT_XL710 | \
IXL_BIT_ULL(I40E_FILTER_PCTYPE_NONF_UNICAST_IPV4_UDP) | \
IXL_BIT_ULL(I40E_FILTER_PCTYPE_NONF_MULTICAST_IPV4_UDP) | \
IXL_BIT_ULL(I40E_FILTER_PCTYPE_NONF_UNICAST_IPV6_UDP) | \
IXL_BIT_ULL(I40E_FILTER_PCTYPE_NONF_MULTICAST_IPV6_UDP) | \
IXL_BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_TCP_SYN_NO_ACK) | \
IXL_BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_TCP_SYN_NO_ACK))
#define IXL_RSS_VSI_LUT_SIZE 64
#define IXL_RSS_KEY_SIZE_REG 13
#define IXL_RSS_KEY_SIZE (IXL_RSS_KEY_SIZE_REG * sizeof(uint32_t))
enum i40e_reset_type {
I40E_RESET_POR = 0,
I40E_RESET_CORER = 1,
@ -144,6 +170,37 @@ struct ixl_aq_desc {
#define IXL_AQ_OP_RSS_GET_KEY 0x0b04
#define IXL_AQ_OP_RSS_GET_LUT 0x0b05
static inline void
ixl_aq_dva(struct ixl_aq_desc *iaq, bus_addr_t addr)
{
uint64_t val;
if (sizeof(addr) > 4) {
val = (intptr_t)addr;
iaq->iaq_param[2] = htole32(val >> 32);
} else {
iaq->iaq_param[2] = htole32(0);
}
iaq->iaq_param[3] = htole32(addr);
}
static inline bool
ixl_aq_has_dva(struct ixl_aq_desc *iaq)
{
uint64_t val;
if (sizeof(bus_addr_t) > 4) {
val = le32toh(iaq->iaq_param[2]);
val = val << 32;
} else {
val = 0;
}
val |= htole32(iaq->iaq_param[3]);
return !(val == 0);
}
struct ixl_aq_mac_addresses {
uint8_t pf_lan[ETHER_ADDR_LEN];
uint8_t pf_san[ETHER_ADDR_LEN];
@ -926,4 +983,90 @@ enum i40e_mac_type {
#define IXL_NVM_OEMBUILD_MASK (0xffffUL << IXL_NVM_OEMBUILD_SHIFT)
#define IXL_NVM_OEMPATCH_SHIFT 0
#define IXL_NVM_OEMPATCH_MASK (0xff << IXL_NVM_OEMPATCH_SHIFT)
struct ixl_aq_buf {
SIMPLEQ_ENTRY(ixl_aq_buf)
aqb_entry;
void *aqb_data;
bus_dmamap_t aqb_map;
bus_dma_segment_t aqb_seg;
size_t aqb_size;
int aqb_nsegs;
};
SIMPLEQ_HEAD(ixl_aq_bufs, ixl_aq_buf);
#define IXL_AQB_MAP(_aqb) ((_aqb)->aqb_map)
#define IXL_AQB_DVA(_aqb) ((_aqb)->aqb_map->dm_segs[0].ds_addr)
#define IXL_AQB_KVA(_aqb) ((void *)(_aqb)->aqb_data)
#define IXL_AQB_LEN(_aqb) ((_aqb)->aqb_size)
static inline unsigned int
ixl_rxr_unrefreshed(unsigned int prod, unsigned int cons, unsigned int ndescs)
{
unsigned int num;
if (prod < cons)
num = cons - prod;
else
num = (ndescs - prod) + cons;
if (__predict_true(num > 0)) {
/* device cannot receive packets if all descripter is filled */
num -= 1;
}
return num;
}
struct ixl_dmamem {
bus_dmamap_t ixm_map;
bus_dma_segment_t ixm_seg;
int ixm_nsegs;
size_t ixm_size;
void *ixm_kva;
};
#define IXL_DMA_MAP(_ixm) ((_ixm)->ixm_map)
#define IXL_DMA_DVA(_ixm) ((_ixm)->ixm_map->dm_segs[0].ds_addr)
#define IXL_DMA_KVA(_ixm) ((void *)(_ixm)->ixm_kva)
#define IXL_DMA_LEN(_ixm) ((_ixm)->ixm_size)
static inline uint32_t
ixl_dmamem_hi(struct ixl_dmamem *ixm)
{
uint32_t retval;
uint64_t val;
if (sizeof(IXL_DMA_DVA(ixm)) > 4) {
val = (intptr_t)IXL_DMA_DVA(ixm);
retval = val >> 32;
} else {
retval = 0;
}
return retval;
}
static inline uint32_t
ixl_dmamem_lo(struct ixl_dmamem *ixm)
{
return (uint32_t)IXL_DMA_DVA(ixm);
}
struct i40e_eth_stats {
uint64_t rx_bytes;
uint64_t rx_unicast;
uint64_t rx_multicast;
uint64_t rx_broadcast;
uint64_t rx_discards;
uint64_t rx_unknown_protocol;
uint64_t tx_bytes;
uint64_t tx_unicast;
uint64_t tx_multicast;
uint64_t tx_broadcast;
uint64_t tx_discards;
uint64_t tx_errors;
} __packed;
#endif

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.244 2020/04/04 15:43:21 jdolecek Exp $
# $NetBSD: Makefile,v 1.245 2020/09/08 10:05:47 yamaguchi Exp $
.include <bsd.own.mk>
@ -235,6 +235,7 @@ SUBDIR+= nvmm
${MACHINE_ARCH} == "i386" || \
${MACHINE_ARCH} == "x86_64"
#SUBDIR+= hifn
SUBDIR+= if_iavf
SUBDIR+= if_ixl
SUBDIR+= ubsec
.endif

View File

@ -0,0 +1,12 @@
# $NetBSD: Makefile,v 1.1 2020/09/08 10:05:48 yamaguchi Exp $
.include "../Makefile.inc"
.PATH: ${S}/dev/pci
KMOD= if_iavf
IOCONF= if_iavf.ioconf
SRCS+= if_iavf.c
.include <bsd.kmodule.mk>

View File

@ -0,0 +1,10 @@
# $NetBSD: if_iavf.ioconf,v 1.1 2020/09/08 10:05:48 yamaguchi Exp $
ioconf if_iavf
include "conf/files"
include "dev/pci/files.pci"
pseudo-root pci*
iavf* at pci? dev ? function ?