0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 #ifndef _CXGB3_OFFLOAD_H
0033 #define _CXGB3_OFFLOAD_H
0034
0035 #include <linux/list.h>
0036 #include <linux/skbuff.h>
0037
0038 #include "l2t.h"
0039
0040 #include "t3cdev.h"
0041 #include "t3_cpl.h"
0042
0043 struct adapter;
0044
0045 void cxgb3_offload_init(void);
0046
0047 void cxgb3_adapter_ofld(struct adapter *adapter);
0048 void cxgb3_adapter_unofld(struct adapter *adapter);
0049 int cxgb3_offload_activate(struct adapter *adapter);
0050 void cxgb3_offload_deactivate(struct adapter *adapter);
0051
0052 void cxgb3_set_dummy_ops(struct t3cdev *dev);
0053
0054 struct t3cdev *dev2t3cdev(struct net_device *dev);
0055
0056
0057
0058
0059
0060
0061
0062
0063 void cxgb3_register_client(struct cxgb3_client *client);
0064 void cxgb3_unregister_client(struct cxgb3_client *client);
0065 void cxgb3_add_clients(struct t3cdev *tdev);
0066 void cxgb3_remove_clients(struct t3cdev *tdev);
0067 void cxgb3_event_notify(struct t3cdev *tdev, u32 event, u32 port);
0068
0069 typedef int (*cxgb3_cpl_handler_func)(struct t3cdev *dev,
0070 struct sk_buff *skb, void *ctx);
0071
0072 enum {
0073 OFFLOAD_STATUS_UP,
0074 OFFLOAD_STATUS_DOWN,
0075 OFFLOAD_PORT_DOWN,
0076 OFFLOAD_PORT_UP,
0077 OFFLOAD_DB_FULL,
0078 OFFLOAD_DB_EMPTY,
0079 OFFLOAD_DB_DROP
0080 };
0081
0082 struct cxgb3_client {
0083 char *name;
0084 void (*add) (struct t3cdev *);
0085 void (*remove) (struct t3cdev *);
0086 cxgb3_cpl_handler_func *handlers;
0087 int (*redirect)(void *ctx, struct dst_entry *old,
0088 struct dst_entry *new, struct l2t_entry *l2t);
0089 struct list_head client_list;
0090 void (*event_handler)(struct t3cdev *tdev, u32 event, u32 port);
0091 };
0092
0093
0094
0095
0096 int cxgb3_alloc_atid(struct t3cdev *dev, struct cxgb3_client *client,
0097 void *ctx);
0098 int cxgb3_alloc_stid(struct t3cdev *dev, struct cxgb3_client *client,
0099 void *ctx);
0100 void *cxgb3_free_atid(struct t3cdev *dev, int atid);
0101 void cxgb3_free_stid(struct t3cdev *dev, int stid);
0102 void cxgb3_insert_tid(struct t3cdev *dev, struct cxgb3_client *client,
0103 void *ctx, unsigned int tid);
0104 void cxgb3_queue_tid_release(struct t3cdev *dev, unsigned int tid);
0105 void cxgb3_remove_tid(struct t3cdev *dev, void *ctx, unsigned int tid);
0106
0107 struct t3c_tid_entry {
0108 struct cxgb3_client *client;
0109 void *ctx;
0110 };
0111
0112
0113 enum {
0114 CPL_PRIORITY_DATA = 0,
0115 CPL_PRIORITY_SETUP = 1,
0116 CPL_PRIORITY_TEARDOWN = 0,
0117 CPL_PRIORITY_LISTEN = 1,
0118 CPL_PRIORITY_ACK = 1,
0119 CPL_PRIORITY_CONTROL = 1
0120 };
0121
0122
0123 enum {
0124 CPL_RET_BUF_DONE = 1,
0125 CPL_RET_BAD_MSG = 2,
0126 CPL_RET_UNKNOWN_TID = 4
0127 };
0128
0129 typedef int (*cpl_handler_func)(struct t3cdev *dev, struct sk_buff *skb);
0130
0131
0132
0133
0134
0135 static inline void *cplhdr(struct sk_buff *skb)
0136 {
0137 return skb->data;
0138 }
0139
0140 void t3_register_cpl_handler(unsigned int opcode, cpl_handler_func h);
0141
0142 union listen_entry {
0143 struct t3c_tid_entry t3c_tid;
0144 union listen_entry *next;
0145 };
0146
0147 union active_open_entry {
0148 struct t3c_tid_entry t3c_tid;
0149 union active_open_entry *next;
0150 };
0151
0152
0153
0154
0155
0156
0157 struct tid_info {
0158 struct t3c_tid_entry *tid_tab;
0159 unsigned int ntids;
0160 atomic_t tids_in_use;
0161
0162 union listen_entry *stid_tab;
0163 unsigned int nstids;
0164 unsigned int stid_base;
0165
0166 union active_open_entry *atid_tab;
0167 unsigned int natids;
0168 unsigned int atid_base;
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178 spinlock_t atid_lock ____cacheline_aligned_in_smp;
0179 union active_open_entry *afree;
0180 unsigned int atids_in_use;
0181
0182 spinlock_t stid_lock ____cacheline_aligned;
0183 union listen_entry *sfree;
0184 unsigned int stids_in_use;
0185 };
0186
0187 struct t3c_data {
0188 struct list_head list_node;
0189 struct t3cdev *dev;
0190 unsigned int tx_max_chunk;
0191 unsigned int max_wrs;
0192 unsigned int nmtus;
0193 const unsigned short *mtus;
0194 struct tid_info tid_maps;
0195
0196 struct t3c_tid_entry *tid_release_list;
0197 spinlock_t tid_release_lock;
0198 struct work_struct tid_release_task;
0199
0200 struct sk_buff *nofail_skb;
0201 unsigned int release_list_incomplete;
0202 };
0203
0204
0205
0206
0207 #define T3C_DATA(dev) (*(struct t3c_data **)&(dev)->l4opt)
0208
0209 #endif