* Copyright 2010-2017 Intel Corporation.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2,
* as published by the Free Software Foundation.
* This 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.
* Disclaimer: The codes contained in these modules may be specific to
* the Intel Software Development Platform codenamed Knights Ferry,
* and the Intel product codenamed Knights Corner, and are not backward
* compatible with other Intel products. Additionally, Intel will NOT
* support the codes or instruction set in future products.
* Intel offers no warranty of any kind regarding the code. This code is
* licensed on an "AS IS" basis and Intel is not obligated to provide
* any support, assistance, installation, training, or other services
* of any kind. Intel is also not obligated to provide any updates,
* enhancements or extensions. Intel specifically disclaims any warranty
* of merchantability, non-infringement, fitness for any particular
* purpose, and any other warranty.
* Further, Intel disclaims all liability of any kind, including but
* not limited to liability for infringement of any proprietary rights,
* relating to the use of the code, even if Intel is notified of the
* possibility of such liability. Except as expressly stated in an Intel
* license agreement provided with this code and agreed upon with Intel,
* no license, express or implied, by estoppel or otherwise, to any
* intellectual property rights is granted herein.
#include <linux/kernel.h>
#include <linux/hardirq.h>
#include <linux/capability.h>
#include <linux/string.h>
#include <linux/vmalloc.h>
#include <linux/kernel.h>
#include <linux/mm_types.h>
#include <linux/jiffies.h>
#include <linux/irqflags.h>
#include <linux/spinlock.h>
#include <linux/semaphore.h>
#include <linux/kthread.h>
#include <linux/device.h>
#include <linux/workqueue.h>
#include <linux/interrupt.h>
#include <linux/netdevice.h>
#include <linux/debugfs.h>
Define this if only DMA mode is supported without legacy POLL/INTR modes
(i.e if only micveth_dma.c is included in the host/card side drivers, i.e
when linvnet.c is excluded from host side driver and micveth.c from card
side driver). This will ensure that other global symbols which are at
present common with legacy modes (in linvnet.c/micveth.c) are all included
#undef STANDALONE_VNET_DMA
/*******************************************************/
#define MICVNET_MSG_RB_SIZE 128
#define DMA_ALIGNMENT L1_CACHE_BYTES
/* The maximum total number of outstanding messages possible in the current
implementation is 2 * VNET_MAX_SKBS + 1. */
#if (MICVNET_MSG_RB_SIZE < 2 * VNET_MAX_SKBS + 2)
#error "MICVNET_MSG_RB_SIZE should be at least (2 * VNET_MAX_SKBS + 2)"
#if (MICVNET_MSG_RB_SIZE & (MICVNET_MSG_RB_SIZE - 1))
#error "MICVNET_MSG_RB_SIZE should be power of 2"
MICVNET_MSG_ADD_DMA_BUFFER
,
MICVNET_MSG_DMA_COMPLETE
,
struct micvnet_msg_add_dma_buffer
{
struct micvnet_msg_dma_complete
{
#define VNET_DRIVER_VERSION 1
struct micvnet_msg_link_up
{
uint64_t vnet_driver_version
;
struct micvnet_msg_add_dma_buffer micvnet_msg_add_dma_buffer
;
struct micvnet_msg_dma_complete micvnet_msg_dma_complete
;
struct micvnet_msg_link_up micvnet_msg_link_up
;
union micvnet_msg_body body
;
struct micvnet_msg buf
[MICVNET_MSG_RB_SIZE
];
volatile uint32_t prev_head
;
volatile uint32_t prev_tail
;
struct micvnet_msg_ring_pair
{
struct micvnet_msg_rb rb_tx
;
struct micvnet_msg_rb rb_rx
;
struct micvnet_msg_rb
*tx
;
struct micvnet_msg_rb
*rx
;
/*******************************************************/
/* Restict micvnet mtu to 63K because ping does not work on RHEL 6.3 with 64K
#define MICVNET_MAX_MTU (63 * 1024)
#define MICVNET_CARD_UP_MAGIC 0x1A77BBEE
unsigned char *skb_data_aligned
;
struct net_device
*vi_netdev
;
struct workqueue_struct
*vi_wq
;
struct work_struct vi_ws_bh
;
struct work_struct vi_ws_tx
;
struct work_struct vi_ws_dmacb
;
struct work_struct vi_ws_link_down
;
struct work_struct vi_ws_stop
;
struct work_struct vi_ws_start
;
struct micvnet_msg_ring_pair vi_rp
;
struct micvnet_msg_ring_pair
*ring_ptr
;
struct micvnet_msg_qp vi_qp
;
struct obj_list dnode_list
;
struct list_head vi_rx_skb
;
struct list_head vi_dma_buf
;
struct list_head vi_tx_skb
;
struct list_head vi_sched_skb
;
mic_dma_handle_t dma_handle
;
struct dma_channel
*dma_chan
;
struct dma_completion_cb dma_cb
;
atomic_t cnt_dma_complete
;
atomic_t cnt_dma_buf_avail
;
bool link_down_initiator
;
wait_queue_head_t stop_waitq
;
atomic_t lv_active_clients
;
int micvnet_init(struct device
*dev
);
int micvnet_probe(mic_ctx_t
*mic_ctx
);
void micvnet_remove(mic_ctx_t
*mic_ctx
);
int micvnet_xmit(struct sk_buff
*skb
, struct net_device
*dev
);
int micvnet_start(mic_ctx_t
*mic_ctx
);
void micvnet_stop(mic_ctx_t
*mic_ctx
);
int __init
micvnet_module_init(void);
void __exit
micvnet_module_exit(void);
#ifdef STANDALONE_VNET_DMA
#define micveth_init micvnet_init
#define micveth_exit micvnet_exit
#define micveth_probe micvnet_probe
#define micveth_remove micvnet_remove
#define micveth_start micvnet_start
#define micveth_stop micvnet_stop
extern int vnet_num_buffers
;