/* * This file is provided under a dual BSD/GPLv2 license. When using or * redistributing this file, you may do so under either license. * * GPL LICENSE SUMMARY * * Copyright(c) 2012 Intel Corporation. All rights reserved. * Copyright (C) 2015 EMC Corporation. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * BSD LICENSE * * Copyright(c) 2012 Intel Corporation. All rights reserved. * Copyright (C) 2015 EMC Corporation. All Rights Reserved. * * 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 copy * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT * OWNER 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. * * PCIe NTB Network Linux driver * * Contact Information: * Jon Mason <[email protected]> */ #include <linux/etherdevice.h> #include <linux/ethtool.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/ntb.h> #include <linux/ntb_transport.h> #define NTB_NETDEV_VER … MODULE_DESCRIPTION(…); MODULE_VERSION(…); MODULE_LICENSE(…) …; MODULE_AUTHOR(…) …; /* Time in usecs for tx resource reaper */ static unsigned int tx_time = …; /* Number of descriptors to free before resuming tx */ static unsigned int tx_start = …; /* Number of descriptors still available before stop upper layer tx */ static unsigned int tx_stop = …; struct ntb_netdev { … }; #define NTB_TX_TIMEOUT_MS … #define NTB_RXQ_SIZE … static void ntb_netdev_event_handler(void *data, int link_is_up) { … } static void ntb_netdev_rx_handler(struct ntb_transport_qp *qp, void *qp_data, void *data, int len) { … } static int __ntb_netdev_maybe_stop_tx(struct net_device *netdev, struct ntb_transport_qp *qp, int size) { … } static int ntb_netdev_maybe_stop_tx(struct net_device *ndev, struct ntb_transport_qp *qp, int size) { … } static void ntb_netdev_tx_handler(struct ntb_transport_qp *qp, void *qp_data, void *data, int len) { … } static netdev_tx_t ntb_netdev_start_xmit(struct sk_buff *skb, struct net_device *ndev) { … } static void ntb_netdev_tx_timer(struct timer_list *t) { … } static int ntb_netdev_open(struct net_device *ndev) { … } static int ntb_netdev_close(struct net_device *ndev) { … } static int ntb_netdev_change_mtu(struct net_device *ndev, int new_mtu) { … } static const struct net_device_ops ntb_netdev_ops = …; static void ntb_get_drvinfo(struct net_device *ndev, struct ethtool_drvinfo *info) { … } static int ntb_get_link_ksettings(struct net_device *dev, struct ethtool_link_ksettings *cmd) { … } static const struct ethtool_ops ntb_ethtool_ops = …; static const struct ntb_queue_handlers ntb_netdev_handlers = …; static int ntb_netdev_probe(struct device *client_dev) { … } static void ntb_netdev_remove(struct device *client_dev) { … } static struct ntb_transport_client ntb_netdev_client = …; static int __init ntb_netdev_init_module(void) { … } late_initcall(ntb_netdev_init_module); static void __exit ntb_netdev_exit_module(void) { … } module_exit(ntb_netdev_exit_module);