xref: /freebsd/sys/dev/ixgbe/ixgbe_sriov.h (revision 71625ec9ad2a9bc8c09784fbd23b759830e0ee5f)
18eb6488eSEric Joyner /******************************************************************************
28eb6488eSEric Joyner 
38455e365SKevin Bowling   Copyright (c) 2001-2020, Intel Corporation
48eb6488eSEric Joyner   All rights reserved.
58eb6488eSEric Joyner 
68eb6488eSEric Joyner   Redistribution and use in source and binary forms, with or without
78eb6488eSEric Joyner   modification, are permitted provided that the following conditions are met:
88eb6488eSEric Joyner 
98eb6488eSEric Joyner    1. Redistributions of source code must retain the above copyright notice,
108eb6488eSEric Joyner       this list of conditions and the following disclaimer.
118eb6488eSEric Joyner 
128eb6488eSEric Joyner    2. Redistributions in binary form must reproduce the above copyright
138eb6488eSEric Joyner       notice, this list of conditions and the following disclaimer in the
148eb6488eSEric Joyner       documentation and/or other materials provided with the distribution.
158eb6488eSEric Joyner 
168eb6488eSEric Joyner    3. Neither the name of the Intel Corporation nor the names of its
178eb6488eSEric Joyner       contributors may be used to endorse or promote products derived from
188eb6488eSEric Joyner       this software without specific prior written permission.
198eb6488eSEric Joyner 
208eb6488eSEric Joyner   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
218eb6488eSEric Joyner   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
228eb6488eSEric Joyner   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
238eb6488eSEric Joyner   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
248eb6488eSEric Joyner   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
258eb6488eSEric Joyner   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
268eb6488eSEric Joyner   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
278eb6488eSEric Joyner   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
288eb6488eSEric Joyner   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
298eb6488eSEric Joyner   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
308eb6488eSEric Joyner   POSSIBILITY OF SUCH DAMAGE.
318eb6488eSEric Joyner 
328eb6488eSEric Joyner ******************************************************************************/
338eb6488eSEric Joyner 
348eb6488eSEric Joyner 
358eb6488eSEric Joyner #ifndef _IXGBE_SRIOV_H_
368eb6488eSEric Joyner #define _IXGBE_SRIOV_H_
378eb6488eSEric Joyner 
388eb6488eSEric Joyner #ifdef PCI_IOV
398eb6488eSEric Joyner 
408eb6488eSEric Joyner #include <sys/nv.h>
418eb6488eSEric Joyner #include <sys/iov_schema.h>
428eb6488eSEric Joyner #include <dev/pci/pci_iov.h>
43c19c7afeSEric Joyner #include <net/iflib.h>
448eb6488eSEric Joyner #include "ixgbe_mbx.h"
458eb6488eSEric Joyner 
468eb6488eSEric Joyner #define IXGBE_VF_CTS            (1 << 0) /* VF is clear to send. */
478eb6488eSEric Joyner #define IXGBE_VF_CAP_MAC        (1 << 1) /* VF is permitted to change MAC. */
488eb6488eSEric Joyner #define IXGBE_VF_CAP_VLAN       (1 << 2) /* VF is permitted to join vlans. */
498eb6488eSEric Joyner #define IXGBE_VF_ACTIVE         (1 << 3) /* VF is active. */
508eb6488eSEric Joyner #define IXGBE_VF_INDEX(vmdq)    ((vmdq) / 32)
518eb6488eSEric Joyner #define IXGBE_VF_BIT(vmdq)      (1 << ((vmdq) % 32))
528eb6488eSEric Joyner 
538eb6488eSEric Joyner #define IXGBE_VT_MSG_MASK	0xFFFF
548eb6488eSEric Joyner 
558eb6488eSEric Joyner #define IXGBE_VT_MSGINFO(msg)	\
568eb6488eSEric Joyner 	(((msg) & IXGBE_VT_MSGINFO_MASK) >> IXGBE_VT_MSGINFO_SHIFT)
578eb6488eSEric Joyner 
588eb6488eSEric Joyner #define IXGBE_VF_GET_QUEUES_RESP_LEN	5
598eb6488eSEric Joyner 
608eb6488eSEric Joyner #define IXGBE_API_VER_1_0	0
618eb6488eSEric Joyner #define IXGBE_API_VER_2_0	1	/* Solaris API.  Not supported. */
628eb6488eSEric Joyner #define IXGBE_API_VER_1_1	2
638eb6488eSEric Joyner #define IXGBE_API_VER_UNKNOWN	UINT16_MAX
648eb6488eSEric Joyner 
658eb6488eSEric Joyner #define IXGBE_NO_VM             0
668eb6488eSEric Joyner #define IXGBE_32_VM             32
678eb6488eSEric Joyner #define IXGBE_64_VM             64
688eb6488eSEric Joyner 
69c19c7afeSEric Joyner int  ixgbe_if_iov_vf_add(if_ctx_t, u16, const nvlist_t *);
70c19c7afeSEric Joyner int  ixgbe_if_iov_init(if_ctx_t, u16, const nvlist_t *);
71c19c7afeSEric Joyner void ixgbe_if_iov_uninit(if_ctx_t);
72*b1d5caf3SKevin Bowling void ixgbe_initialize_iov(struct ixgbe_softc *);
73*b1d5caf3SKevin Bowling void ixgbe_recalculate_max_frame(struct ixgbe_softc *);
74*b1d5caf3SKevin Bowling void ixgbe_ping_all_vfs(struct ixgbe_softc *);
758eb6488eSEric Joyner int  ixgbe_pci_iov_detach(device_t);
768eb6488eSEric Joyner void ixgbe_define_iov_schemas(device_t, int *);
77*b1d5caf3SKevin Bowling void ixgbe_align_all_queue_indices(struct ixgbe_softc *);
78c19c7afeSEric Joyner int  ixgbe_vf_que_index(int, int, int);
798eb6488eSEric Joyner u32  ixgbe_get_mtqc(int);
808eb6488eSEric Joyner u32  ixgbe_get_mrqc(int);
818eb6488eSEric Joyner 
828eb6488eSEric Joyner /******************************************************************************/
838eb6488eSEric Joyner #else  /* PCI_IOV */
848eb6488eSEric Joyner /******************************************************************************/
858eb6488eSEric Joyner 
868eb6488eSEric Joyner #define ixgbe_add_vf(_a,_b,_c)
878eb6488eSEric Joyner #define ixgbe_init_iov(_a,_b,_c)
888eb6488eSEric Joyner #define ixgbe_uninit_iov(_a)
898eb6488eSEric Joyner #define ixgbe_initialize_iov(_a)
908eb6488eSEric Joyner #define ixgbe_recalculate_max_frame(_a)
918eb6488eSEric Joyner #define ixgbe_ping_all_vfs(_a)
928eb6488eSEric Joyner #define ixgbe_pci_iov_detach(_a) 0
938eb6488eSEric Joyner #define ixgbe_define_iov_schemas(_a,_b)
948eb6488eSEric Joyner #define ixgbe_align_all_queue_indices(_a)
95c19c7afeSEric Joyner #define ixgbe_vf_que_index(_a, _b, _c) (_c)
968eb6488eSEric Joyner #define ixgbe_get_mtqc(_a) IXGBE_MTQC_64Q_1PB
978eb6488eSEric Joyner #define ixgbe_get_mrqc(_a) 0
988eb6488eSEric Joyner 
998eb6488eSEric Joyner #endif /* PCI_IOV */
1008eb6488eSEric Joyner 
101c19c7afeSEric Joyner void ixgbe_if_init(if_ctx_t ctx);
102c19c7afeSEric Joyner void ixgbe_handle_mbx(void *);
1038eb6488eSEric Joyner 
1048eb6488eSEric Joyner #endif
105