/drivers/net/mlx4/mlx4_en.h
C Header | 605 lines | 455 code | 89 blank | 61 comment | 9 complexity | 35f0c25924aeaece6a65f0cb51e761cd MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
- /*
- * Copyright (c) 2007 Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
- #ifndef _MLX4_EN_H_
- #define _MLX4_EN_H_
- #include <linux/compiler.h>
- #include <linux/list.h>
- #include <linux/mutex.h>
- #include <linux/netdevice.h>
- #include <linux/mlx4/device.h>
- #include <linux/mlx4/qp.h>
- #include <linux/mlx4/cq.h>
- #include <linux/mlx4/srq.h>
- #include <linux/mlx4/doorbell.h>
- #include <linux/mlx4/cmd.h>
- #include "en_port.h"
- #define DRV_NAME "mlx4_en"
- #define DRV_VERSION "1.5.4.1"
- #define DRV_RELDATE "March 2011"
- #define MLX4_EN_MSG_LEVEL (NETIF_MSG_LINK | NETIF_MSG_IFDOWN)
- /*
- * Device constants
- */
- #define MLX4_EN_PAGE_SHIFT 12
- #define MLX4_EN_PAGE_SIZE (1 << MLX4_EN_PAGE_SHIFT)
- #define MAX_RX_RINGS 16
- #define MIN_RX_RINGS 4
- #define TXBB_SIZE 64
- #define HEADROOM (2048 / TXBB_SIZE + 1)
- #define STAMP_STRIDE 64
- #define STAMP_DWORDS (STAMP_STRIDE / 4)
- #define STAMP_SHIFT 31
- #define STAMP_VAL 0x7fffffff
- #define STATS_DELAY (HZ / 4)
- /* Typical TSO descriptor with 16 gather entries is 352 bytes... */
- #define MAX_DESC_SIZE 512
- #define MAX_DESC_TXBBS (MAX_DESC_SIZE / TXBB_SIZE)
- /*
- * OS related constants and tunables
- */
- #define MLX4_EN_WATCHDOG_TIMEOUT (15 * HZ)
- #define MLX4_EN_ALLOC_ORDER 2
- #define MLX4_EN_ALLOC_SIZE (PAGE_SIZE << MLX4_EN_ALLOC_ORDER)
- #define MLX4_EN_MAX_LRO_DESCRIPTORS 32
- /* Receive fragment sizes; we use at most 4 fragments (for 9600 byte MTU
- * and 4K allocations) */
- enum {
- FRAG_SZ0 = 512 - NET_IP_ALIGN,
- FRAG_SZ1 = 1024,
- FRAG_SZ2 = 4096,
- FRAG_SZ3 = MLX4_EN_ALLOC_SIZE
- };
- #define MLX4_EN_MAX_RX_FRAGS 4
- /* Maximum ring sizes */
- #define MLX4_EN_MAX_TX_SIZE 8192
- #define MLX4_EN_MAX_RX_SIZE 8192
- /* Minimum ring size for our page-allocation sceme to work */
- #define MLX4_EN_MIN_RX_SIZE (MLX4_EN_ALLOC_SIZE / SMP_CACHE_BYTES)
- #define MLX4_EN_MIN_TX_SIZE (4096 / TXBB_SIZE)
- #define MLX4_EN_SMALL_PKT_SIZE 64
- #define MLX4_EN_NUM_TX_RINGS 8
- #define MLX4_EN_NUM_PPP_RINGS 8
- #define MAX_TX_RINGS (MLX4_EN_NUM_TX_RINGS + MLX4_EN_NUM_PPP_RINGS)
- #define MLX4_EN_DEF_TX_RING_SIZE 512
- #define MLX4_EN_DEF_RX_RING_SIZE 1024
- /* Target number of packets to coalesce with interrupt moderation */
- #define MLX4_EN_RX_COAL_TARGET 44
- #define MLX4_EN_RX_COAL_TIME 0x10
- #define MLX4_EN_TX_COAL_PKTS 5
- #define MLX4_EN_TX_COAL_TIME 0x80
- #define MLX4_EN_RX_RATE_LOW 400000
- #define MLX4_EN_RX_COAL_TIME_LOW 0
- #define MLX4_EN_RX_RATE_HIGH 450000
- #define MLX4_EN_RX_COAL_TIME_HIGH 128
- #define MLX4_EN_RX_SIZE_THRESH 1024
- #define MLX4_EN_RX_RATE_THRESH (1000000 / MLX4_EN_RX_COAL_TIME_HIGH)
- #define MLX4_EN_SAMPLE_INTERVAL 0
- #define MLX4_EN_AVG_PKT_SMALL 256
- #define MLX4_EN_AUTO_CONF 0xffff
- #define MLX4_EN_DEF_RX_PAUSE 1
- #define MLX4_EN_DEF_TX_PAUSE 1
- /* Interval between successive polls in the Tx routine when polling is used
- instead of interrupts (in per-core Tx rings) - should be power of 2 */
- #define MLX4_EN_TX_POLL_MODER 16
- #define MLX4_EN_TX_POLL_TIMEOUT (HZ / 4)
- #define ETH_LLC_SNAP_SIZE 8
- #define SMALL_PACKET_SIZE (256 - NET_IP_ALIGN)
- #define HEADER_COPY_SIZE (128 - NET_IP_ALIGN)
- #define MLX4_LOOPBACK_TEST_PAYLOAD (HEADER_COPY_SIZE - ETH_HLEN)
- #define MLX4_EN_MIN_MTU 46
- #define ETH_BCAST 0xffffffffffffULL
- #define MLX4_EN_LOOPBACK_RETRIES 5
- #define MLX4_EN_LOOPBACK_TIMEOUT 100
- #ifdef MLX4_EN_PERF_STAT
- /* Number of samples to 'average' */
- #define AVG_SIZE 128
- #define AVG_FACTOR 1024
- #define NUM_PERF_STATS NUM_PERF_COUNTERS
- #define INC_PERF_COUNTER(cnt) (++(cnt))
- #define ADD_PERF_COUNTER(cnt, add) ((cnt) += (add))
- #define AVG_PERF_COUNTER(cnt, sample) \
- ((cnt) = ((cnt) * (AVG_SIZE - 1) + (sample) * AVG_FACTOR) / AVG_SIZE)
- #define GET_PERF_COUNTER(cnt) (cnt)
- #define GET_AVG_PERF_COUNTER(cnt) ((cnt) / AVG_FACTOR)
- #else
- #define NUM_PERF_STATS 0
- #define INC_PERF_COUNTER(cnt) do {} while (0)
- #define ADD_PERF_COUNTER(cnt, add) do {} while (0)
- #define AVG_PERF_COUNTER(cnt, sample) do {} while (0)
- #define GET_PERF_COUNTER(cnt) (0)
- #define GET_AVG_PERF_COUNTER(cnt) (0)
- #endif /* MLX4_EN_PERF_STAT */
- /*
- * Configurables
- */
- enum cq_type {
- RX = 0,
- TX = 1,
- };
- /*
- * Useful macros
- */
- #define ROUNDUP_LOG2(x) ilog2(roundup_pow_of_two(x))
- #define XNOR(x, y) (!(x) == !(y))
- #define ILLEGAL_MAC(addr) (addr == 0xffffffffffffULL || addr == 0x0)
- struct mlx4_en_tx_info {
- struct sk_buff *skb;
- u32 nr_txbb;
- u8 linear;
- u8 data_offset;
- u8 inl;
- };
- #define MLX4_EN_BIT_DESC_OWN 0x80000000
- #define CTRL_SIZE sizeof(struct mlx4_wqe_ctrl_seg)
- #define MLX4_EN_MEMTYPE_PAD 0x100
- #define DS_SIZE sizeof(struct mlx4_wqe_data_seg)
- struct mlx4_en_tx_desc {
- struct mlx4_wqe_ctrl_seg ctrl;
- union {
- struct mlx4_wqe_data_seg data; /* at least one data segment */
- struct mlx4_wqe_lso_seg lso;
- struct mlx4_wqe_inline_seg inl;
- };
- };
- #define MLX4_EN_USE_SRQ 0x01000000
- #define MLX4_EN_CX3_LOW_ID 0x1000
- #define MLX4_EN_CX3_HIGH_ID 0x1005
- struct mlx4_en_rx_alloc {
- struct page *page;
- u16 offset;
- };
- struct mlx4_en_tx_ring {
- struct mlx4_hwq_resources wqres;
- u32 size ; /* number of TXBBs */
- u32 size_mask;
- u16 stride;
- u16 cqn; /* index of port CQ associated with this ring */
- u32 prod;
- u32 cons;
- u32 buf_size;
- u32 doorbell_qpn;
- void *buf;
- u16 poll_cnt;
- int blocked;
- struct mlx4_en_tx_info *tx_info;
- u8 *bounce_buf;
- u32 last_nr_txbb;
- struct mlx4_qp qp;
- struct mlx4_qp_context context;
- int qpn;
- enum mlx4_qp_state qp_state;
- struct mlx4_srq dummy;
-