1 /* QLogic qed NIC Driver
3 * Copyright (c) 2015 QLogic Corporation
5 * This software is available under the terms of the GNU General Public License
6 * (GPL) Version 2, available from the file COPYING in the main directory of
13 #include <linux/types.h>
14 #include <linux/interrupt.h>
15 #include <linux/netdevice.h>
16 #include <linux/pci.h>
17 #include <linux/skbuff.h>
18 #include <linux/version.h>
19 #include <linux/kernel.h>
20 #include <linux/slab.h>
21 #include <linux/qed/qed_if.h>
23 struct qed_ll2_stats {
25 u64 gsi_invalid_pkt_length;
26 u64 gsi_unsupported_pkt_typ;
27 u64 gsi_crcchksm_error;
29 u64 packet_too_big_discard;
47 #define QED_LL2_UNUSED_HANDLE (0xff)
49 struct qed_ll2_cb_ops {
50 int (*rx_cb)(void *, struct sk_buff *, u32, u32);
51 int (*tx_cb)(void *, struct sk_buff *, bool);
54 struct qed_ll2_params {
56 bool drop_ttl0_packets;
57 bool rx_vlan_stripping;
60 u8 ll2_mac_address[ETH_ALEN];
65 * @brief start - initializes ll2
68 * @param params - protocol driver configuration for the ll2.
70 * @return 0 on success, otherwise error value.
72 int (*start)(struct qed_dev *cdev, struct qed_ll2_params *params);
75 * @brief stop - stops the ll2
79 * @return 0 on success, otherwise error value.
81 int (*stop)(struct qed_dev *cdev);
84 * @brief start_xmit - transmits an skb over the ll2 interface
89 * @return 0 on success, otherwise error value.
91 int (*start_xmit)(struct qed_dev *cdev, struct sk_buff *skb);
94 * @brief register_cb_ops - protocol driver register the callback for Rx/Tx
95 * packets. Should be called before `start'.
98 * @param cookie - to be passed to the callback functions.
99 * @param ops - the callback functions to register for Rx / Tx.
101 * @return 0 on success, otherwise error value.
103 void (*register_cb_ops)(struct qed_dev *cdev,
104 const struct qed_ll2_cb_ops *ops,
108 * @brief get LL2 related statistics
111 * @param stats - pointer to struct that would be filled with stats
113 * @return 0 on success, error otherwise.
115 int (*get_stats)(struct qed_dev *cdev, struct qed_ll2_stats *stats);
118 #ifdef CONFIG_QED_LL2
119 int qed_ll2_alloc_if(struct qed_dev *);
120 void qed_ll2_dealloc_if(struct qed_dev *);
122 static const struct qed_ll2_ops qed_ll2_ops_pass = {
126 .register_cb_ops = NULL,
130 static inline int qed_ll2_alloc_if(struct qed_dev *cdev)
135 static inline void qed_ll2_dealloc_if(struct qed_dev *cdev)