iwch_cm.c 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229
  1. /*
  2. * Copyright (c) 2006 Chelsio, Inc. All rights reserved.
  3. *
  4. * This software is available to you under a choice of one of two
  5. * licenses. You may choose to be licensed under the terms of the GNU
  6. * General Public License (GPL) Version 2, available from the file
  7. * COPYING in the main directory of this source tree, or the
  8. * OpenIB.org BSD license below:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  18. * - Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer in the documentation and/or other materials
  21. * provided with the distribution.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30. * SOFTWARE.
  31. */
  32. #include <linux/module.h>
  33. #include <linux/list.h>
  34. #include <linux/workqueue.h>
  35. #include <linux/skbuff.h>
  36. #include <linux/timer.h>
  37. #include <linux/notifier.h>
  38. #include <linux/inetdevice.h>
  39. #include <net/neighbour.h>
  40. #include <net/netevent.h>
  41. #include <net/route.h>
  42. #include "tcb.h"
  43. #include "cxgb3_offload.h"
  44. #include "iwch.h"
  45. #include "iwch_provider.h"
  46. #include "iwch_cm.h"
  47. static char *states[] = {
  48. "idle",
  49. "listen",
  50. "connecting",
  51. "mpa_wait_req",
  52. "mpa_req_sent",
  53. "mpa_req_rcvd",
  54. "mpa_rep_sent",
  55. "fpdu_mode",
  56. "aborting",
  57. "closing",
  58. "moribund",
  59. "dead",
  60. NULL,
  61. };
  62. int peer2peer = 0;
  63. module_param(peer2peer, int, 0644);
  64. MODULE_PARM_DESC(peer2peer, "Support peer2peer ULPs (default=0)");
  65. static int ep_timeout_secs = 60;
  66. module_param(ep_timeout_secs, int, 0644);
  67. MODULE_PARM_DESC(ep_timeout_secs, "CM Endpoint operation timeout "
  68. "in seconds (default=60)");
  69. static int mpa_rev = 1;
  70. module_param(mpa_rev, int, 0644);
  71. MODULE_PARM_DESC(mpa_rev, "MPA Revision, 0 supports amso1100, "
  72. "1 is spec compliant. (default=1)");
  73. static int markers_enabled = 0;
  74. module_param(markers_enabled, int, 0644);
  75. MODULE_PARM_DESC(markers_enabled, "Enable MPA MARKERS (default(0)=disabled)");
  76. static int crc_enabled = 1;
  77. module_param(crc_enabled, int, 0644);
  78. MODULE_PARM_DESC(crc_enabled, "Enable MPA CRC (default(1)=enabled)");
  79. static int rcv_win = 256 * 1024;
  80. module_param(rcv_win, int, 0644);
  81. MODULE_PARM_DESC(rcv_win, "TCP receive window in bytes (default=256)");
  82. static int snd_win = 32 * 1024;
  83. module_param(snd_win, int, 0644);
  84. MODULE_PARM_DESC(snd_win, "TCP send window in bytes (default=32KB)");
  85. static unsigned int nocong = 0;
  86. module_param(nocong, uint, 0644);
  87. MODULE_PARM_DESC(nocong, "Turn off congestion control (default=0)");
  88. static unsigned int cong_flavor = 1;
  89. module_param(cong_flavor, uint, 0644);
  90. MODULE_PARM_DESC(cong_flavor, "TCP Congestion control flavor (default=1)");
  91. static void process_work(struct work_struct *work);
  92. static struct workqueue_struct *workq;
  93. static DECLARE_WORK(skb_work, process_work);
  94. static struct sk_buff_head rxq;
  95. static cxgb3_cpl_handler_func work_handlers[NUM_CPL_CMDS];
  96. static struct sk_buff *get_skb(struct sk_buff *skb, int len, gfp_t gfp);
  97. static void ep_timeout(unsigned long arg);
  98. static void connect_reply_upcall(struct iwch_ep *ep, int status);
  99. static void start_ep_timer(struct iwch_ep *ep)
  100. {
  101. PDBG("%s ep %p\n", __func__, ep);
  102. if (timer_pending(&ep->timer)) {
  103. PDBG("%s stopped / restarted timer ep %p\n", __func__, ep);
  104. del_timer_sync(&ep->timer);
  105. } else
  106. get_ep(&ep->com);
  107. ep->timer.expires = jiffies + ep_timeout_secs * HZ;
  108. ep->timer.data = (unsigned long)ep;
  109. ep->timer.function = ep_timeout;
  110. add_timer(&ep->timer);
  111. }
  112. static void stop_ep_timer(struct iwch_ep *ep)
  113. {
  114. PDBG("%s ep %p\n", __func__, ep);
  115. if (!timer_pending(&ep->timer)) {
  116. printk(KERN_ERR "%s timer stopped when its not running! ep %p state %u\n",
  117. __func__, ep, ep->com.state);
  118. WARN_ON(1);
  119. return;
  120. }
  121. del_timer_sync(&ep->timer);
  122. put_ep(&ep->com);
  123. }
  124. int iwch_l2t_send(struct t3cdev *tdev, struct sk_buff *skb, struct l2t_entry *l2e)
  125. {
  126. int error = 0;
  127. struct cxio_rdev *rdev;
  128. rdev = (struct cxio_rdev *)tdev->ulp;
  129. if (cxio_fatal_error(rdev)) {
  130. kfree_skb(skb);
  131. return -EIO;
  132. }
  133. error = l2t_send(tdev, skb, l2e);
  134. if (error)
  135. kfree_skb(skb);
  136. return error;
  137. }
  138. int iwch_cxgb3_ofld_send(struct t3cdev *tdev, struct sk_buff *skb)
  139. {
  140. int error = 0;
  141. struct cxio_rdev *rdev;
  142. rdev = (struct cxio_rdev *)tdev->ulp;
  143. if (cxio_fatal_error(rdev)) {
  144. kfree_skb(skb);
  145. return -EIO;
  146. }
  147. error = cxgb3_ofld_send(tdev, skb);
  148. if (error)
  149. kfree_skb(skb);
  150. return error;
  151. }
  152. static void release_tid(struct t3cdev *tdev, u32 hwtid, struct sk_buff *skb)
  153. {
  154. struct cpl_tid_release *req;
  155. skb = get_skb(skb, sizeof *req, GFP_KERNEL);
  156. if (!skb)
  157. return;
  158. req = (struct cpl_tid_release *) skb_put(skb, sizeof(*req));
  159. req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD));
  160. OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_TID_RELEASE, hwtid));
  161. skb->priority = CPL_PRIORITY_SETUP;
  162. iwch_cxgb3_ofld_send(tdev, skb);
  163. return;
  164. }
  165. int iwch_quiesce_tid(struct iwch_ep *ep)
  166. {
  167. struct cpl_set_tcb_field *req;
  168. struct sk_buff *skb = get_skb(NULL, sizeof(*req), GFP_KERNEL);
  169. if (!skb)
  170. return -ENOMEM;
  171. req = (struct cpl_set_tcb_field *) skb_put(skb, sizeof(*req));
  172. req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD));
  173. req->wr.wr_lo = htonl(V_WR_TID(ep->hwtid));
  174. OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_SET_TCB_FIELD, ep->hwtid));
  175. req->reply = 0;
  176. req->cpu_idx = 0;
  177. req->word = htons(W_TCB_RX_QUIESCE);
  178. req->mask = cpu_to_be64(1ULL << S_TCB_RX_QUIESCE);
  179. req->val = cpu_to_be64(1 << S_TCB_RX_QUIESCE);
  180. skb->priority = CPL_PRIORITY_DATA;
  181. return iwch_cxgb3_ofld_send(ep->com.tdev, skb);
  182. }
  183. int iwch_resume_tid(struct iwch_ep *ep)
  184. {
  185. struct cpl_set_tcb_field *req;
  186. struct sk_buff *skb = get_skb(NULL, sizeof(*req), GFP_KERNEL);
  187. if (!skb)
  188. return -ENOMEM;
  189. req = (struct cpl_set_tcb_field *) skb_put(skb, sizeof(*req));
  190. req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD));
  191. req->wr.wr_lo = htonl(V_WR_TID(ep->hwtid));
  192. OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_SET_TCB_FIELD, ep->hwtid));
  193. req->reply = 0;
  194. req->cpu_idx = 0;
  195. req->word = htons(W_TCB_RX_QUIESCE);
  196. req->mask = cpu_to_be64(1ULL << S_TCB_RX_QUIESCE);
  197. req->val = 0;
  198. skb->priority = CPL_PRIORITY_DATA;
  199. return iwch_cxgb3_ofld_send(ep->com.tdev, skb);
  200. }
  201. static void set_emss(struct iwch_ep *ep, u16 opt)
  202. {
  203. PDBG("%s ep %p opt %u\n", __func__, ep, opt);
  204. ep->emss = T3C_DATA(ep->com.tdev)->mtus[G_TCPOPT_MSS(opt)] - 40;
  205. if (G_TCPOPT_TSTAMP(opt))
  206. ep->emss -= 12;
  207. if (ep->emss < 128)
  208. ep->emss = 128;
  209. PDBG("emss=%d\n", ep->emss);
  210. }
  211. static enum iwch_ep_state state_read(struct iwch_ep_common *epc)
  212. {
  213. unsigned long flags;
  214. enum iwch_ep_state state;
  215. spin_lock_irqsave(&epc->lock, flags);
  216. state = epc->state;
  217. spin_unlock_irqrestore(&epc->lock, flags);
  218. return state;
  219. }
  220. static void __state_set(struct iwch_ep_common *epc, enum iwch_ep_state new)
  221. {
  222. epc->state = new;
  223. }
  224. static void state_set(struct iwch_ep_common *epc, enum iwch_ep_state new)
  225. {
  226. unsigned long flags;
  227. spin_lock_irqsave(&epc->lock, flags);
  228. PDBG("%s - %s -> %s\n", __func__, states[epc->state], states[new]);
  229. __state_set(epc, new);
  230. spin_unlock_irqrestore(&epc->lock, flags);
  231. return;
  232. }
  233. static void *alloc_ep(int size, gfp_t gfp)
  234. {
  235. struct iwch_ep_common *epc;
  236. epc = kzalloc(size, gfp);
  237. if (epc) {
  238. kref_init(&epc->kref);
  239. spin_lock_init(&epc->lock);
  240. init_waitqueue_head(&epc->waitq);
  241. }
  242. PDBG("%s alloc ep %p\n", __func__, epc);
  243. return epc;
  244. }
  245. void __free_ep(struct kref *kref)
  246. {
  247. struct iwch_ep_common *epc;
  248. epc = container_of(kref, struct iwch_ep_common, kref);
  249. PDBG("%s ep %p state %s\n", __func__, epc, states[state_read(epc)]);
  250. kfree(epc);
  251. }
  252. static void release_ep_resources(struct iwch_ep *ep)
  253. {
  254. PDBG("%s ep %p tid %d\n", __func__, ep, ep->hwtid);
  255. cxgb3_remove_tid(ep->com.tdev, (void *)ep, ep->hwtid);
  256. dst_release(ep->dst);
  257. l2t_release(L2DATA(ep->com.tdev), ep->l2t);
  258. put_ep(&ep->com);
  259. }
  260. static void process_work(struct work_struct *work)
  261. {
  262. struct sk_buff *skb = NULL;
  263. void *ep;
  264. struct t3cdev *tdev;
  265. int ret;
  266. while ((skb = skb_dequeue(&rxq))) {
  267. ep = *((void **) (skb->cb));
  268. tdev = *((struct t3cdev **) (skb->cb + sizeof(void *)));
  269. ret = work_handlers[G_OPCODE(ntohl((__force __be32)skb->csum))](tdev, skb, ep);
  270. if (ret & CPL_RET_BUF_DONE)
  271. kfree_skb(skb);
  272. /*
  273. * ep was referenced in sched(), and is freed here.
  274. */
  275. put_ep((struct iwch_ep_common *)ep);
  276. }
  277. }
  278. static int status2errno(int status)
  279. {
  280. switch (status) {
  281. case CPL_ERR_NONE:
  282. return 0;
  283. case CPL_ERR_CONN_RESET:
  284. return -ECONNRESET;
  285. case CPL_ERR_ARP_MISS:
  286. return -EHOSTUNREACH;
  287. case CPL_ERR_CONN_TIMEDOUT:
  288. return -ETIMEDOUT;
  289. case CPL_ERR_TCAM_FULL:
  290. return -ENOMEM;
  291. case CPL_ERR_CONN_EXIST:
  292. return -EADDRINUSE;
  293. default:
  294. return -EIO;
  295. }
  296. }
  297. /*
  298. * Try and reuse skbs already allocated...
  299. */
  300. static struct sk_buff *get_skb(struct sk_buff *skb, int len, gfp_t gfp)
  301. {
  302. if (skb && !skb_is_nonlinear(skb) && !skb_cloned(skb)) {
  303. skb_trim(skb, 0);
  304. skb_get(skb);
  305. } else {
  306. skb = alloc_skb(len, gfp);
  307. }
  308. return skb;
  309. }
  310. static struct rtable *find_route(struct t3cdev *dev, __be32 local_ip,
  311. __be32 peer_ip, __be16 local_port,
  312. __be16 peer_port, u8 tos)
  313. {
  314. struct rtable *rt;
  315. struct flowi fl = {
  316. .oif = 0,
  317. .nl_u = {
  318. .ip4_u = {
  319. .daddr = peer_ip,
  320. .saddr = local_ip,
  321. .tos = tos}
  322. },
  323. .proto = IPPROTO_TCP,
  324. .uli_u = {
  325. .ports = {
  326. .sport = local_port,
  327. .dport = peer_port}
  328. }
  329. };
  330. if (ip_route_output_flow(&init_net, &rt, &fl, NULL, 0))
  331. return NULL;
  332. return rt;
  333. }
  334. static unsigned int find_best_mtu(const struct t3c_data *d, unsigned short mtu)
  335. {
  336. int i = 0;
  337. while (i < d->nmtus - 1 && d->mtus[i + 1] <= mtu)
  338. ++i;
  339. return i;
  340. }
  341. static void arp_failure_discard(struct t3cdev *dev, struct sk_buff *skb)
  342. {
  343. PDBG("%s t3cdev %p\n", __func__, dev);
  344. kfree_skb(skb);
  345. }
  346. /*
  347. * Handle an ARP failure for an active open.
  348. */
  349. static void act_open_req_arp_failure(struct t3cdev *dev, struct sk_buff *skb)
  350. {
  351. printk(KERN_ERR MOD "ARP failure duing connect\n");
  352. kfree_skb(skb);
  353. }
  354. /*
  355. * Handle an ARP failure for a CPL_ABORT_REQ. Change it into a no RST variant
  356. * and send it along.
  357. */
  358. static void abort_arp_failure(struct t3cdev *dev, struct sk_buff *skb)
  359. {
  360. struct cpl_abort_req *req = cplhdr(skb);
  361. PDBG("%s t3cdev %p\n", __func__, dev);
  362. req->cmd = CPL_ABORT_NO_RST;
  363. iwch_cxgb3_ofld_send(dev, skb);
  364. }
  365. static int send_halfclose(struct iwch_ep *ep, gfp_t gfp)
  366. {
  367. struct cpl_close_con_req *req;
  368. struct sk_buff *skb;
  369. PDBG("%s ep %p\n", __func__, ep);
  370. skb = get_skb(NULL, sizeof(*req), gfp);
  371. if (!skb) {
  372. printk(KERN_ERR MOD "%s - failed to alloc skb\n", __func__);
  373. return -ENOMEM;
  374. }
  375. skb->priority = CPL_PRIORITY_DATA;
  376. set_arp_failure_handler(skb, arp_failure_discard);
  377. req = (struct cpl_close_con_req *) skb_put(skb, sizeof(*req));
  378. req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_CLOSE_CON));
  379. req->wr.wr_lo = htonl(V_WR_TID(ep->hwtid));
  380. OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_CLOSE_CON_REQ, ep->hwtid));
  381. return iwch_l2t_send(ep->com.tdev, skb, ep->l2t);
  382. }
  383. static int send_abort(struct iwch_ep *ep, struct sk_buff *skb, gfp_t gfp)
  384. {
  385. struct cpl_abort_req *req;
  386. PDBG("%s ep %p\n", __func__, ep);
  387. skb = get_skb(skb, sizeof(*req), gfp);
  388. if (!skb) {
  389. printk(KERN_ERR MOD "%s - failed to alloc skb.\n",
  390. __func__);
  391. return -ENOMEM;
  392. }
  393. skb->priority = CPL_PRIORITY_DATA;
  394. set_arp_failure_handler(skb, abort_arp_failure);
  395. req = (struct cpl_abort_req *) skb_put(skb, sizeof(*req));
  396. req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_HOST_ABORT_CON_REQ));
  397. req->wr.wr_lo = htonl(V_WR_TID(ep->hwtid));
  398. OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_ABORT_REQ, ep->hwtid));
  399. req->cmd = CPL_ABORT_SEND_RST;
  400. return iwch_l2t_send(ep->com.tdev, skb, ep->l2t);
  401. }
  402. static int send_connect(struct iwch_ep *ep)
  403. {
  404. struct cpl_act_open_req *req;
  405. struct sk_buff *skb;
  406. u32 opt0h, opt0l, opt2;
  407. unsigned int mtu_idx;
  408. int wscale;
  409. PDBG("%s ep %p\n", __func__, ep);
  410. skb = get_skb(NULL, sizeof(*req), GFP_KERNEL);
  411. if (!skb) {
  412. printk(KERN_ERR MOD "%s - failed to alloc skb.\n",
  413. __func__);
  414. return -ENOMEM;
  415. }
  416. mtu_idx = find_best_mtu(T3C_DATA(ep->com.tdev), dst_mtu(ep->dst));
  417. wscale = compute_wscale(rcv_win);
  418. opt0h = V_NAGLE(0) |
  419. V_NO_CONG(nocong) |
  420. V_KEEP_ALIVE(1) |
  421. F_TCAM_BYPASS |
  422. V_WND_SCALE(wscale) |
  423. V_MSS_IDX(mtu_idx) |
  424. V_L2T_IDX(ep->l2t->idx) | V_TX_CHANNEL(ep->l2t->smt_idx);
  425. opt0l = V_TOS((ep->tos >> 2) & M_TOS) | V_RCV_BUFSIZ(rcv_win>>10);
  426. opt2 = V_FLAVORS_VALID(1) | V_CONG_CONTROL_FLAVOR(cong_flavor);
  427. skb->priority = CPL_PRIORITY_SETUP;
  428. set_arp_failure_handler(skb, act_open_req_arp_failure);
  429. req = (struct cpl_act_open_req *) skb_put(skb, sizeof(*req));
  430. req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD));
  431. OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_ACT_OPEN_REQ, ep->atid));
  432. req->local_port = ep->com.local_addr.sin_port;
  433. req->peer_port = ep->com.remote_addr.sin_port;
  434. req->local_ip = ep->com.local_addr.sin_addr.s_addr;
  435. req->peer_ip = ep->com.remote_addr.sin_addr.s_addr;
  436. req->opt0h = htonl(opt0h);
  437. req->opt0l = htonl(opt0l);
  438. req->params = 0;
  439. req->opt2 = htonl(opt2);
  440. return iwch_l2t_send(ep->com.tdev, skb, ep->l2t);
  441. }
  442. static void send_mpa_req(struct iwch_ep *ep, struct sk_buff *skb)
  443. {
  444. int mpalen;
  445. struct tx_data_wr *req;
  446. struct mpa_message *mpa;
  447. int len;
  448. PDBG("%s ep %p pd_len %d\n", __func__, ep, ep->plen);
  449. BUG_ON(skb_cloned(skb));
  450. mpalen = sizeof(*mpa) + ep->plen;
  451. if (skb->data + mpalen + sizeof(*req) > skb_end_pointer(skb)) {
  452. kfree_skb(skb);
  453. skb=alloc_skb(mpalen + sizeof(*req), GFP_KERNEL);
  454. if (!skb) {
  455. connect_reply_upcall(ep, -ENOMEM);
  456. return;
  457. }
  458. }
  459. skb_trim(skb, 0);
  460. skb_reserve(skb, sizeof(*req));
  461. skb_put(skb, mpalen);
  462. skb->priority = CPL_PRIORITY_DATA;
  463. mpa = (struct mpa_message *) skb->data;
  464. memset(mpa, 0, sizeof(*mpa));
  465. memcpy(mpa->key, MPA_KEY_REQ, sizeof(mpa->key));
  466. mpa->flags = (crc_enabled ? MPA_CRC : 0) |
  467. (markers_enabled ? MPA_MARKERS : 0);
  468. mpa->private_data_size = htons(ep->plen);
  469. mpa->revision = mpa_rev;
  470. if (ep->plen)
  471. memcpy(mpa->private_data, ep->mpa_pkt + sizeof(*mpa), ep->plen);
  472. /*
  473. * Reference the mpa skb. This ensures the data area
  474. * will remain in memory until the hw acks the tx.
  475. * Function tx_ack() will deref it.
  476. */
  477. skb_get(skb);
  478. set_arp_failure_handler(skb, arp_failure_discard);
  479. skb_reset_transport_header(skb);
  480. len = skb->len;
  481. req = (struct tx_data_wr *) skb_push(skb, sizeof(*req));
  482. req->wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_TX_DATA)|F_WR_COMPL);
  483. req->wr_lo = htonl(V_WR_TID(ep->hwtid));
  484. req->len = htonl(len);
  485. req->param = htonl(V_TX_PORT(ep->l2t->smt_idx) |
  486. V_TX_SNDBUF(snd_win>>15));
  487. req->flags = htonl(F_TX_INIT);
  488. req->sndseq = htonl(ep->snd_seq);
  489. BUG_ON(ep->mpa_skb);
  490. ep->mpa_skb = skb;
  491. iwch_l2t_send(ep->com.tdev, skb, ep->l2t);
  492. start_ep_timer(ep);
  493. state_set(&ep->com, MPA_REQ_SENT);
  494. return;
  495. }
  496. static int send_mpa_reject(struct iwch_ep *ep, const void *pdata, u8 plen)
  497. {
  498. int mpalen;
  499. struct tx_data_wr *req;
  500. struct mpa_message *mpa;
  501. struct sk_buff *skb;
  502. PDBG("%s ep %p plen %d\n", __func__, ep, plen);
  503. mpalen = sizeof(*mpa) + plen;
  504. skb = get_skb(NULL, mpalen + sizeof(*req), GFP_KERNEL);
  505. if (!skb) {
  506. printk(KERN_ERR MOD "%s - cannot alloc skb!\n", __func__);
  507. return -ENOMEM;
  508. }
  509. skb_reserve(skb, sizeof(*req));
  510. mpa = (struct mpa_message *) skb_put(skb, mpalen);
  511. memset(mpa, 0, sizeof(*mpa));
  512. memcpy(mpa->key, MPA_KEY_REP, sizeof(mpa->key));
  513. mpa->flags = MPA_REJECT;
  514. mpa->revision = mpa_rev;
  515. mpa->private_data_size = htons(plen);
  516. if (plen)
  517. memcpy(mpa->private_data, pdata, plen);
  518. /*
  519. * Reference the mpa skb again. This ensures the data area
  520. * will remain in memory until the hw acks the tx.
  521. * Function tx_ack() will deref it.
  522. */
  523. skb_get(skb);
  524. skb->priority = CPL_PRIORITY_DATA;
  525. set_arp_failure_handler(skb, arp_failure_discard);
  526. skb_reset_transport_header(skb);
  527. req = (struct tx_data_wr *) skb_push(skb, sizeof(*req));
  528. req->wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_TX_DATA)|F_WR_COMPL);
  529. req->wr_lo = htonl(V_WR_TID(ep->hwtid));
  530. req->len = htonl(mpalen);
  531. req->param = htonl(V_TX_PORT(ep->l2t->smt_idx) |
  532. V_TX_SNDBUF(snd_win>>15));
  533. req->flags = htonl(F_TX_INIT);
  534. req->sndseq = htonl(ep->snd_seq);
  535. BUG_ON(ep->mpa_skb);
  536. ep->mpa_skb = skb;
  537. return iwch_l2t_send(ep->com.tdev, skb, ep->l2t);
  538. }
  539. static int send_mpa_reply(struct iwch_ep *ep, const void *pdata, u8 plen)
  540. {
  541. int mpalen;
  542. struct tx_data_wr *req;
  543. struct mpa_message *mpa;
  544. int len;
  545. struct sk_buff *skb;
  546. PDBG("%s ep %p plen %d\n", __func__, ep, plen);
  547. mpalen = sizeof(*mpa) + plen;
  548. skb = get_skb(NULL, mpalen + sizeof(*req), GFP_KERNEL);
  549. if (!skb) {
  550. printk(KERN_ERR MOD "%s - cannot alloc skb!\n", __func__);
  551. return -ENOMEM;
  552. }
  553. skb->priority = CPL_PRIORITY_DATA;
  554. skb_reserve(skb, sizeof(*req));
  555. mpa = (struct mpa_message *) skb_put(skb, mpalen);
  556. memset(mpa, 0, sizeof(*mpa));
  557. memcpy(mpa->key, MPA_KEY_REP, sizeof(mpa->key));
  558. mpa->flags = (ep->mpa_attr.crc_enabled ? MPA_CRC : 0) |
  559. (markers_enabled ? MPA_MARKERS : 0);
  560. mpa->revision = mpa_rev;
  561. mpa->private_data_size = htons(plen);
  562. if (plen)
  563. memcpy(mpa->private_data, pdata, plen);
  564. /*
  565. * Reference the mpa skb. This ensures the data area
  566. * will remain in memory until the hw acks the tx.
  567. * Function tx_ack() will deref it.
  568. */
  569. skb_get(skb);
  570. set_arp_failure_handler(skb, arp_failure_discard);
  571. skb_reset_transport_header(skb);
  572. len = skb->len;
  573. req = (struct tx_data_wr *) skb_push(skb, sizeof(*req));
  574. req->wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_TX_DATA)|F_WR_COMPL);
  575. req->wr_lo = htonl(V_WR_TID(ep->hwtid));
  576. req->len = htonl(len);
  577. req->param = htonl(V_TX_PORT(ep->l2t->smt_idx) |
  578. V_TX_SNDBUF(snd_win>>15));
  579. req->flags = htonl(F_TX_INIT);
  580. req->sndseq = htonl(ep->snd_seq);
  581. ep->mpa_skb = skb;
  582. state_set(&ep->com, MPA_REP_SENT);
  583. return iwch_l2t_send(ep->com.tdev, skb, ep->l2t);
  584. }
  585. static int act_establish(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
  586. {
  587. struct iwch_ep *ep = ctx;
  588. struct cpl_act_establish *req = cplhdr(skb);
  589. unsigned int tid = GET_TID(req);
  590. PDBG("%s ep %p tid %d\n", __func__, ep, tid);
  591. dst_confirm(ep->dst);
  592. /* setup the hwtid for this connection */
  593. ep->hwtid = tid;
  594. cxgb3_insert_tid(ep->com.tdev, &t3c_client, ep, tid);
  595. ep->snd_seq = ntohl(req->snd_isn);
  596. ep->rcv_seq = ntohl(req->rcv_isn);
  597. set_emss(ep, ntohs(req->tcp_opt));
  598. /* dealloc the atid */
  599. cxgb3_free_atid(ep->com.tdev, ep->atid);
  600. /* start MPA negotiation */
  601. send_mpa_req(ep, skb);
  602. return 0;
  603. }
  604. static void abort_connection(struct iwch_ep *ep, struct sk_buff *skb, gfp_t gfp)
  605. {
  606. PDBG("%s ep %p\n", __FILE__, ep);
  607. state_set(&ep->com, ABORTING);
  608. send_abort(ep, skb, gfp);
  609. }
  610. static void close_complete_upcall(struct iwch_ep *ep)
  611. {
  612. struct iw_cm_event event;
  613. PDBG("%s ep %p\n", __func__, ep);
  614. memset(&event, 0, sizeof(event));
  615. event.event = IW_CM_EVENT_CLOSE;
  616. if (ep->com.cm_id) {
  617. PDBG("close complete delivered ep %p cm_id %p tid %d\n",
  618. ep, ep->com.cm_id, ep->hwtid);
  619. ep->com.cm_id->event_handler(ep->com.cm_id, &event);
  620. ep->com.cm_id->rem_ref(ep->com.cm_id);
  621. ep->com.cm_id = NULL;
  622. ep->com.qp = NULL;
  623. }
  624. }
  625. static void peer_close_upcall(struct iwch_ep *ep)
  626. {
  627. struct iw_cm_event event;
  628. PDBG("%s ep %p\n", __func__, ep);
  629. memset(&event, 0, sizeof(event));
  630. event.event = IW_CM_EVENT_DISCONNECT;
  631. if (ep->com.cm_id) {
  632. PDBG("peer close delivered ep %p cm_id %p tid %d\n",
  633. ep, ep->com.cm_id, ep->hwtid);
  634. ep->com.cm_id->event_handler(ep->com.cm_id, &event);
  635. }
  636. }
  637. static void peer_abort_upcall(struct iwch_ep *ep)
  638. {
  639. struct iw_cm_event event;
  640. PDBG("%s ep %p\n", __func__, ep);
  641. memset(&event, 0, sizeof(event));
  642. event.event = IW_CM_EVENT_CLOSE;
  643. event.status = -ECONNRESET;
  644. if (ep->com.cm_id) {
  645. PDBG("abort delivered ep %p cm_id %p tid %d\n", ep,
  646. ep->com.cm_id, ep->hwtid);
  647. ep->com.cm_id->event_handler(ep->com.cm_id, &event);
  648. ep->com.cm_id->rem_ref(ep->com.cm_id);
  649. ep->com.cm_id = NULL;
  650. ep->com.qp = NULL;
  651. }
  652. }
  653. static void connect_reply_upcall(struct iwch_ep *ep, int status)
  654. {
  655. struct iw_cm_event event;
  656. PDBG("%s ep %p status %d\n", __func__, ep, status);
  657. memset(&event, 0, sizeof(event));
  658. event.event = IW_CM_EVENT_CONNECT_REPLY;
  659. event.status = status;
  660. event.local_addr = ep->com.local_addr;
  661. event.remote_addr = ep->com.remote_addr;
  662. if ((status == 0) || (status == -ECONNREFUSED)) {
  663. event.private_data_len = ep->plen;
  664. event.private_data = ep->mpa_pkt + sizeof(struct mpa_message);
  665. }
  666. if (ep->com.cm_id) {
  667. PDBG("%s ep %p tid %d status %d\n", __func__, ep,
  668. ep->hwtid, status);
  669. ep->com.cm_id->event_handler(ep->com.cm_id, &event);
  670. }
  671. if (status < 0) {
  672. ep->com.cm_id->rem_ref(ep->com.cm_id);
  673. ep->com.cm_id = NULL;
  674. ep->com.qp = NULL;
  675. }
  676. }
  677. static void connect_request_upcall(struct iwch_ep *ep)
  678. {
  679. struct iw_cm_event event;
  680. PDBG("%s ep %p tid %d\n", __func__, ep, ep->hwtid);
  681. memset(&event, 0, sizeof(event));
  682. event.event = IW_CM_EVENT_CONNECT_REQUEST;
  683. event.local_addr = ep->com.local_addr;
  684. event.remote_addr = ep->com.remote_addr;
  685. event.private_data_len = ep->plen;
  686. event.private_data = ep->mpa_pkt + sizeof(struct mpa_message);
  687. event.provider_data = ep;
  688. if (state_read(&ep->parent_ep->com) != DEAD)
  689. ep->parent_ep->com.cm_id->event_handler(
  690. ep->parent_ep->com.cm_id,
  691. &event);
  692. put_ep(&ep->parent_ep->com);
  693. ep->parent_ep = NULL;
  694. }
  695. static void established_upcall(struct iwch_ep *ep)
  696. {
  697. struct iw_cm_event event;
  698. PDBG("%s ep %p\n", __func__, ep);
  699. memset(&event, 0, sizeof(event));
  700. event.event = IW_CM_EVENT_ESTABLISHED;
  701. if (ep->com.cm_id) {
  702. PDBG("%s ep %p tid %d\n", __func__, ep, ep->hwtid);
  703. ep->com.cm_id->event_handler(ep->com.cm_id, &event);
  704. }
  705. }
  706. static int update_rx_credits(struct iwch_ep *ep, u32 credits)
  707. {
  708. struct cpl_rx_data_ack *req;
  709. struct sk_buff *skb;
  710. PDBG("%s ep %p credits %u\n", __func__, ep, credits);
  711. skb = get_skb(NULL, sizeof(*req), GFP_KERNEL);
  712. if (!skb) {
  713. printk(KERN_ERR MOD "update_rx_credits - cannot alloc skb!\n");
  714. return 0;
  715. }
  716. req = (struct cpl_rx_data_ack *) skb_put(skb, sizeof(*req));
  717. req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD));
  718. OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_RX_DATA_ACK, ep->hwtid));
  719. req->credit_dack = htonl(V_RX_CREDITS(credits) | V_RX_FORCE_ACK(1));
  720. skb->priority = CPL_PRIORITY_ACK;
  721. iwch_cxgb3_ofld_send(ep->com.tdev, skb);
  722. return credits;
  723. }
  724. static void process_mpa_reply(struct iwch_ep *ep, struct sk_buff *skb)
  725. {
  726. struct mpa_message *mpa;
  727. u16 plen;
  728. struct iwch_qp_attributes attrs;
  729. enum iwch_qp_attr_mask mask;
  730. int err;
  731. PDBG("%s ep %p\n", __func__, ep);
  732. /*
  733. * Stop mpa timer. If it expired, then the state has
  734. * changed and we bail since ep_timeout already aborted
  735. * the connection.
  736. */
  737. stop_ep_timer(ep);
  738. if (state_read(&ep->com) != MPA_REQ_SENT)
  739. return;
  740. /*
  741. * If we get more than the supported amount of private data
  742. * then we must fail this connection.
  743. */
  744. if (ep->mpa_pkt_len + skb->len > sizeof(ep->mpa_pkt)) {
  745. err = -EINVAL;
  746. goto err;
  747. }
  748. /*
  749. * copy the new data into our accumulation buffer.
  750. */
  751. skb_copy_from_linear_data(skb, &(ep->mpa_pkt[ep->mpa_pkt_len]),
  752. skb->len);
  753. ep->mpa_pkt_len += skb->len;
  754. /*
  755. * if we don't even have the mpa message, then bail.
  756. */
  757. if (ep->mpa_pkt_len < sizeof(*mpa))
  758. return;
  759. mpa = (struct mpa_message *) ep->mpa_pkt;
  760. /* Validate MPA header. */
  761. if (mpa->revision != mpa_rev) {
  762. err = -EPROTO;
  763. goto err;
  764. }
  765. if (memcmp(mpa->key, MPA_KEY_REP, sizeof(mpa->key))) {
  766. err = -EPROTO;
  767. goto err;
  768. }
  769. plen = ntohs(mpa->private_data_size);
  770. /*
  771. * Fail if there's too much private data.
  772. */
  773. if (plen > MPA_MAX_PRIVATE_DATA) {
  774. err = -EPROTO;
  775. goto err;
  776. }
  777. /*
  778. * If plen does not account for pkt size
  779. */
  780. if (ep->mpa_pkt_len > (sizeof(*mpa) + plen)) {
  781. err = -EPROTO;
  782. goto err;
  783. }
  784. ep->plen = (u8) plen;
  785. /*
  786. * If we don't have all the pdata yet, then bail.
  787. * We'll continue process when more data arrives.
  788. */
  789. if (ep->mpa_pkt_len < (sizeof(*mpa) + plen))
  790. return;
  791. if (mpa->flags & MPA_REJECT) {
  792. err = -ECONNREFUSED;
  793. goto err;
  794. }
  795. /*
  796. * If we get here we have accumulated the entire mpa
  797. * start reply message including private data. And
  798. * the MPA header is valid.
  799. */
  800. state_set(&ep->com, FPDU_MODE);
  801. ep->mpa_attr.initiator = 1;
  802. ep->mpa_attr.crc_enabled = (mpa->flags & MPA_CRC) | crc_enabled ? 1 : 0;
  803. ep->mpa_attr.recv_marker_enabled = markers_enabled;
  804. ep->mpa_attr.xmit_marker_enabled = mpa->flags & MPA_MARKERS ? 1 : 0;
  805. ep->mpa_attr.version = mpa_rev;
  806. PDBG("%s - crc_enabled=%d, recv_marker_enabled=%d, "
  807. "xmit_marker_enabled=%d, version=%d\n", __func__,
  808. ep->mpa_attr.crc_enabled, ep->mpa_attr.recv_marker_enabled,
  809. ep->mpa_attr.xmit_marker_enabled, ep->mpa_attr.version);
  810. attrs.mpa_attr = ep->mpa_attr;
  811. attrs.max_ird = ep->ird;
  812. attrs.max_ord = ep->ord;
  813. attrs.llp_stream_handle = ep;
  814. attrs.next_state = IWCH_QP_STATE_RTS;
  815. mask = IWCH_QP_ATTR_NEXT_STATE |
  816. IWCH_QP_ATTR_LLP_STREAM_HANDLE | IWCH_QP_ATTR_MPA_ATTR |
  817. IWCH_QP_ATTR_MAX_IRD | IWCH_QP_ATTR_MAX_ORD;
  818. /* bind QP and TID with INIT_WR */
  819. err = iwch_modify_qp(ep->com.qp->rhp,
  820. ep->com.qp, mask, &attrs, 1);
  821. if (err)
  822. goto err;
  823. if (peer2peer && iwch_rqes_posted(ep->com.qp) == 0) {
  824. iwch_post_zb_read(ep->com.qp);
  825. }
  826. goto out;
  827. err:
  828. abort_connection(ep, skb, GFP_KERNEL);
  829. out:
  830. connect_reply_upcall(ep, err);
  831. return;
  832. }
  833. static void process_mpa_request(struct iwch_ep *ep, struct sk_buff *skb)
  834. {
  835. struct mpa_message *mpa;
  836. u16 plen;
  837. PDBG("%s ep %p\n", __func__, ep);
  838. /*
  839. * Stop mpa timer. If it expired, then the state has
  840. * changed and we bail since ep_timeout already aborted
  841. * the connection.
  842. */
  843. stop_ep_timer(ep);
  844. if (state_read(&ep->com) != MPA_REQ_WAIT)
  845. return;
  846. /*
  847. * If we get more than the supported amount of private data
  848. * then we must fail this connection.
  849. */
  850. if (ep->mpa_pkt_len + skb->len > sizeof(ep->mpa_pkt)) {
  851. abort_connection(ep, skb, GFP_KERNEL);
  852. return;
  853. }
  854. PDBG("%s enter (%s line %u)\n", __func__, __FILE__, __LINE__);
  855. /*
  856. * Copy the new data into our accumulation buffer.
  857. */
  858. skb_copy_from_linear_data(skb, &(ep->mpa_pkt[ep->mpa_pkt_len]),
  859. skb->len);
  860. ep->mpa_pkt_len += skb->len;
  861. /*
  862. * If we don't even have the mpa message, then bail.
  863. * We'll continue process when more data arrives.
  864. */
  865. if (ep->mpa_pkt_len < sizeof(*mpa))
  866. return;
  867. PDBG("%s enter (%s line %u)\n", __func__, __FILE__, __LINE__);
  868. mpa = (struct mpa_message *) ep->mpa_pkt;
  869. /*
  870. * Validate MPA Header.
  871. */
  872. if (mpa->revision != mpa_rev) {
  873. abort_connection(ep, skb, GFP_KERNEL);
  874. return;
  875. }
  876. if (memcmp(mpa->key, MPA_KEY_REQ, sizeof(mpa->key))) {
  877. abort_connection(ep, skb, GFP_KERNEL);
  878. return;
  879. }
  880. plen = ntohs(mpa->private_data_size);
  881. /*
  882. * Fail if there's too much private data.
  883. */
  884. if (plen > MPA_MAX_PRIVATE_DATA) {
  885. abort_connection(ep, skb, GFP_KERNEL);
  886. return;
  887. }
  888. /*
  889. * If plen does not account for pkt size
  890. */
  891. if (ep->mpa_pkt_len > (sizeof(*mpa) + plen)) {
  892. abort_connection(ep, skb, GFP_KERNEL);
  893. return;
  894. }
  895. ep->plen = (u8) plen;
  896. /*
  897. * If we don't have all the pdata yet, then bail.
  898. */
  899. if (ep->mpa_pkt_len < (sizeof(*mpa) + plen))
  900. return;
  901. /*
  902. * If we get here we have accumulated the entire mpa
  903. * start reply message including private data.
  904. */
  905. ep->mpa_attr.initiator = 0;
  906. ep->mpa_attr.crc_enabled = (mpa->flags & MPA_CRC) | crc_enabled ? 1 : 0;
  907. ep->mpa_attr.recv_marker_enabled = markers_enabled;
  908. ep->mpa_attr.xmit_marker_enabled = mpa->flags & MPA_MARKERS ? 1 : 0;
  909. ep->mpa_attr.version = mpa_rev;
  910. PDBG("%s - crc_enabled=%d, recv_marker_enabled=%d, "
  911. "xmit_marker_enabled=%d, version=%d\n", __func__,
  912. ep->mpa_attr.crc_enabled, ep->mpa_attr.recv_marker_enabled,
  913. ep->mpa_attr.xmit_marker_enabled, ep->mpa_attr.version);
  914. state_set(&ep->com, MPA_REQ_RCVD);
  915. /* drive upcall */
  916. connect_request_upcall(ep);
  917. return;
  918. }
  919. static int rx_data(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
  920. {
  921. struct iwch_ep *ep = ctx;
  922. struct cpl_rx_data *hdr = cplhdr(skb);
  923. unsigned int dlen = ntohs(hdr->len);
  924. PDBG("%s ep %p dlen %u\n", __func__, ep, dlen);
  925. skb_pull(skb, sizeof(*hdr));
  926. skb_trim(skb, dlen);
  927. ep->rcv_seq += dlen;
  928. BUG_ON(ep->rcv_seq != (ntohl(hdr->seq) + dlen));
  929. switch (state_read(&ep->com)) {
  930. case MPA_REQ_SENT:
  931. process_mpa_reply(ep, skb);
  932. break;
  933. case MPA_REQ_WAIT:
  934. process_mpa_request(ep, skb);
  935. break;
  936. case MPA_REP_SENT:
  937. break;
  938. default:
  939. printk(KERN_ERR MOD "%s Unexpected streaming data."
  940. " ep %p state %d tid %d\n",
  941. __func__, ep, state_read(&ep->com), ep->hwtid);
  942. /*
  943. * The ep will timeout and inform the ULP of the failure.
  944. * See ep_timeout().
  945. */
  946. break;
  947. }
  948. /* update RX credits */
  949. update_rx_credits(ep, dlen);
  950. return CPL_RET_BUF_DONE;
  951. }
  952. /*
  953. * Upcall from the adapter indicating data has been transmitted.
  954. * For us its just the single MPA request or reply. We can now free
  955. * the skb holding the mpa message.
  956. */
  957. static int tx_ack(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
  958. {
  959. struct iwch_ep *ep = ctx;
  960. struct cpl_wr_ack *hdr = cplhdr(skb);
  961. unsigned int credits = ntohs(hdr->credits);
  962. PDBG("%s ep %p credits %u\n", __func__, ep, credits);
  963. if (credits == 0) {
  964. PDBG(KERN_ERR "%s 0 credit ack ep %p state %u\n",
  965. __func__, ep, state_read(&ep->com));
  966. return CPL_RET_BUF_DONE;
  967. }
  968. BUG_ON(credits != 1);
  969. dst_confirm(ep->dst);
  970. if (!ep->mpa_skb) {
  971. PDBG("%s rdma_init wr_ack ep %p state %u\n",
  972. __func__, ep, state_read(&ep->com));
  973. if (ep->mpa_attr.initiator) {
  974. PDBG("%s initiator ep %p state %u\n",
  975. __func__, ep, state_read(&ep->com));
  976. if (peer2peer)
  977. iwch_post_zb_read(ep->com.qp);
  978. } else {
  979. PDBG("%s responder ep %p state %u\n",
  980. __func__, ep, state_read(&ep->com));
  981. ep->com.rpl_done = 1;
  982. wake_up(&ep->com.waitq);
  983. }
  984. } else {
  985. PDBG("%s lsm ack ep %p state %u freeing skb\n",
  986. __func__, ep, state_read(&ep->com));
  987. kfree_skb(ep->mpa_skb);
  988. ep->mpa_skb = NULL;
  989. }
  990. return CPL_RET_BUF_DONE;
  991. }
  992. static int abort_rpl(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
  993. {
  994. struct iwch_ep *ep = ctx;
  995. unsigned long flags;
  996. int release = 0;
  997. PDBG("%s ep %p\n", __func__, ep);
  998. BUG_ON(!ep);
  999. /*
  1000. * We get 2 abort replies from the HW. The first one must
  1001. * be ignored except for scribbling that we need one more.
  1002. */
  1003. if (!(ep->flags & ABORT_REQ_IN_PROGRESS)) {
  1004. ep->flags |= ABORT_REQ_IN_PROGRESS;
  1005. return CPL_RET_BUF_DONE;
  1006. }
  1007. spin_lock_irqsave(&ep->com.lock, flags);
  1008. switch (ep->com.state) {
  1009. case ABORTING:
  1010. close_complete_upcall(ep);
  1011. __state_set(&ep->com, DEAD);
  1012. release = 1;
  1013. break;
  1014. default:
  1015. printk(KERN_ERR "%s ep %p state %d\n",
  1016. __func__, ep, ep->com.state);
  1017. break;
  1018. }
  1019. spin_unlock_irqrestore(&ep->com.lock, flags);
  1020. if (release)
  1021. release_ep_resources(ep);
  1022. return CPL_RET_BUF_DONE;
  1023. }
  1024. /*
  1025. * Return whether a failed active open has allocated a TID
  1026. */
  1027. static inline int act_open_has_tid(int status)
  1028. {
  1029. return status != CPL_ERR_TCAM_FULL && status != CPL_ERR_CONN_EXIST &&
  1030. status != CPL_ERR_ARP_MISS;
  1031. }
  1032. static int act_open_rpl(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
  1033. {
  1034. struct iwch_ep *ep = ctx;
  1035. struct cpl_act_open_rpl *rpl = cplhdr(skb);
  1036. PDBG("%s ep %p status %u errno %d\n", __func__, ep, rpl->status,
  1037. status2errno(rpl->status));
  1038. connect_reply_upcall(ep, status2errno(rpl->status));
  1039. state_set(&ep->com, DEAD);
  1040. if (ep->com.tdev->type != T3A && act_open_has_tid(rpl->status))
  1041. release_tid(ep->com.tdev, GET_TID(rpl), NULL);
  1042. cxgb3_free_atid(ep->com.tdev, ep->atid);
  1043. dst_release(ep->dst);
  1044. l2t_release(L2DATA(ep->com.tdev), ep->l2t);
  1045. put_ep(&ep->com);
  1046. return CPL_RET_BUF_DONE;
  1047. }
  1048. static int listen_start(struct iwch_listen_ep *ep)
  1049. {
  1050. struct sk_buff *skb;
  1051. struct cpl_pass_open_req *req;
  1052. PDBG("%s ep %p\n", __func__, ep);
  1053. skb = get_skb(NULL, sizeof(*req), GFP_KERNEL);
  1054. if (!skb) {
  1055. printk(KERN_ERR MOD "t3c_listen_start failed to alloc skb!\n");
  1056. return -ENOMEM;
  1057. }
  1058. req = (struct cpl_pass_open_req *) skb_put(skb, sizeof(*req));
  1059. req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD));
  1060. OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_PASS_OPEN_REQ, ep->stid));
  1061. req->local_port = ep->com.local_addr.sin_port;
  1062. req->local_ip = ep->com.local_addr.sin_addr.s_addr;
  1063. req->peer_port = 0;
  1064. req->peer_ip = 0;
  1065. req->peer_netmask = 0;
  1066. req->opt0h = htonl(F_DELACK | F_TCAM_BYPASS);
  1067. req->opt0l = htonl(V_RCV_BUFSIZ(rcv_win>>10));
  1068. req->opt1 = htonl(V_CONN_POLICY(CPL_CONN_POLICY_ASK));
  1069. skb->priority = 1;
  1070. return iwch_cxgb3_ofld_send(ep->com.tdev, skb);
  1071. }
  1072. static int pass_open_rpl(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
  1073. {
  1074. struct iwch_listen_ep *ep = ctx;
  1075. struct cpl_pass_open_rpl *rpl = cplhdr(skb);
  1076. PDBG("%s ep %p status %d error %d\n", __func__, ep,
  1077. rpl->status, status2errno(rpl->status));
  1078. ep->com.rpl_err = status2errno(rpl->status);
  1079. ep->com.rpl_done = 1;
  1080. wake_up(&ep->com.waitq);
  1081. return CPL_RET_BUF_DONE;
  1082. }
  1083. static int listen_stop(struct iwch_listen_ep *ep)
  1084. {
  1085. struct sk_buff *skb;
  1086. struct cpl_close_listserv_req *req;
  1087. PDBG("%s ep %p\n", __func__, ep);
  1088. skb = get_skb(NULL, sizeof(*req), GFP_KERNEL);
  1089. if (!skb) {
  1090. printk(KERN_ERR MOD "%s - failed to alloc skb\n", __func__);
  1091. return -ENOMEM;
  1092. }
  1093. req = (struct cpl_close_listserv_req *) skb_put(skb, sizeof(*req));
  1094. req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD));
  1095. req->cpu_idx = 0;
  1096. OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_CLOSE_LISTSRV_REQ, ep->stid));
  1097. skb->priority = 1;
  1098. return iwch_cxgb3_ofld_send(ep->com.tdev, skb);
  1099. }
  1100. static int close_listsrv_rpl(struct t3cdev *tdev, struct sk_buff *skb,
  1101. void *ctx)
  1102. {
  1103. struct iwch_listen_ep *ep = ctx;
  1104. struct cpl_close_listserv_rpl *rpl = cplhdr(skb);
  1105. PDBG("%s ep %p\n", __func__, ep);
  1106. ep->com.rpl_err = status2errno(rpl->status);
  1107. ep->com.rpl_done = 1;
  1108. wake_up(&ep->com.waitq);
  1109. return CPL_RET_BUF_DONE;
  1110. }
  1111. static void accept_cr(struct iwch_ep *ep, __be32 peer_ip, struct sk_buff *skb)
  1112. {
  1113. struct cpl_pass_accept_rpl *rpl;
  1114. unsigned int mtu_idx;
  1115. u32 opt0h, opt0l, opt2;
  1116. int wscale;
  1117. PDBG("%s ep %p\n", __func__, ep);
  1118. BUG_ON(skb_cloned(skb));
  1119. skb_trim(skb, sizeof(*rpl));
  1120. skb_get(skb);
  1121. mtu_idx = find_best_mtu(T3C_DATA(ep->com.tdev), dst_mtu(ep->dst));
  1122. wscale = compute_wscale(rcv_win);
  1123. opt0h = V_NAGLE(0) |
  1124. V_NO_CONG(nocong) |
  1125. V_KEEP_ALIVE(1) |
  1126. F_TCAM_BYPASS |
  1127. V_WND_SCALE(wscale) |
  1128. V_MSS_IDX(mtu_idx) |
  1129. V_L2T_IDX(ep->l2t->idx) | V_TX_CHANNEL(ep->l2t->smt_idx);
  1130. opt0l = V_TOS((ep->tos >> 2) & M_TOS) | V_RCV_BUFSIZ(rcv_win>>10);
  1131. opt2 = V_FLAVORS_VALID(1) | V_CONG_CONTROL_FLAVOR(cong_flavor);
  1132. rpl = cplhdr(skb);
  1133. rpl->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD));
  1134. OPCODE_TID(rpl) = htonl(MK_OPCODE_TID(CPL_PASS_ACCEPT_RPL, ep->hwtid));
  1135. rpl->peer_ip = peer_ip;
  1136. rpl->opt0h = htonl(opt0h);
  1137. rpl->opt0l_status = htonl(opt0l | CPL_PASS_OPEN_ACCEPT);
  1138. rpl->opt2 = htonl(opt2);
  1139. rpl->rsvd = rpl->opt2; /* workaround for HW bug */
  1140. skb->priority = CPL_PRIORITY_SETUP;
  1141. iwch_l2t_send(ep->com.tdev, skb, ep->l2t);
  1142. return;
  1143. }
  1144. static void reject_cr(struct t3cdev *tdev, u32 hwtid, __be32 peer_ip,
  1145. struct sk_buff *skb)
  1146. {
  1147. PDBG("%s t3cdev %p tid %u peer_ip %x\n", __func__, tdev, hwtid,
  1148. peer_ip);
  1149. BUG_ON(skb_cloned(skb));
  1150. skb_trim(skb, sizeof(struct cpl_tid_release));
  1151. skb_get(skb);
  1152. if (tdev->type != T3A)
  1153. release_tid(tdev, hwtid, skb);
  1154. else {
  1155. struct cpl_pass_accept_rpl *rpl;
  1156. rpl = cplhdr(skb);
  1157. skb->priority = CPL_PRIORITY_SETUP;
  1158. rpl->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD));
  1159. OPCODE_TID(rpl) = htonl(MK_OPCODE_TID(CPL_PASS_ACCEPT_RPL,
  1160. hwtid));
  1161. rpl->peer_ip = peer_ip;
  1162. rpl->opt0h = htonl(F_TCAM_BYPASS);
  1163. rpl->opt0l_status = htonl(CPL_PASS_OPEN_REJECT);
  1164. rpl->opt2 = 0;
  1165. rpl->rsvd = rpl->opt2;
  1166. iwch_cxgb3_ofld_send(tdev, skb);
  1167. }
  1168. }
  1169. static int pass_accept_req(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
  1170. {
  1171. struct iwch_ep *child_ep, *parent_ep = ctx;
  1172. struct cpl_pass_accept_req *req = cplhdr(skb);
  1173. unsigned int hwtid = GET_TID(req);
  1174. struct dst_entry *dst;
  1175. struct l2t_entry *l2t;
  1176. struct rtable *rt;
  1177. struct iff_mac tim;
  1178. PDBG("%s parent ep %p tid %u\n", __func__, parent_ep, hwtid);
  1179. if (state_read(&parent_ep->com) != LISTEN) {
  1180. printk(KERN_ERR "%s - listening ep not in LISTEN\n",
  1181. __func__);
  1182. goto reject;
  1183. }
  1184. /*
  1185. * Find the netdev for this connection request.
  1186. */
  1187. tim.mac_addr = req->dst_mac;
  1188. tim.vlan_tag = ntohs(req->vlan_tag);
  1189. if (tdev->ctl(tdev, GET_IFF_FROM_MAC, &tim) < 0 || !tim.dev) {
  1190. printk(KERN_ERR
  1191. "%s bad dst mac %02x %02x %02x %02x %02x %02x\n",
  1192. __func__,
  1193. req->dst_mac[0],
  1194. req->dst_mac[1],
  1195. req->dst_mac[2],
  1196. req->dst_mac[3],
  1197. req->dst_mac[4],
  1198. req->dst_mac[5]);
  1199. goto reject;
  1200. }
  1201. /* Find output route */
  1202. rt = find_route(tdev,
  1203. req->local_ip,
  1204. req->peer_ip,
  1205. req->local_port,
  1206. req->peer_port, G_PASS_OPEN_TOS(ntohl(req->tos_tid)));
  1207. if (!rt) {
  1208. printk(KERN_ERR MOD "%s - failed to find dst entry!\n",
  1209. __func__);
  1210. goto reject;
  1211. }
  1212. dst = &rt->u.dst;
  1213. l2t = t3_l2t_get(tdev, dst->neighbour, dst->neighbour->dev);
  1214. if (!l2t) {
  1215. printk(KERN_ERR MOD "%s - failed to allocate l2t entry!\n",
  1216. __func__);
  1217. dst_release(dst);
  1218. goto reject;
  1219. }
  1220. child_ep = alloc_ep(sizeof(*child_ep), GFP_KERNEL);
  1221. if (!child_ep) {
  1222. printk(KERN_ERR MOD "%s - failed to allocate ep entry!\n",
  1223. __func__);
  1224. l2t_release(L2DATA(tdev), l2t);
  1225. dst_release(dst);
  1226. goto reject;
  1227. }
  1228. state_set(&child_ep->com, CONNECTING);
  1229. child_ep->com.tdev = tdev;
  1230. child_ep->com.cm_id = NULL;
  1231. child_ep->com.local_addr.sin_family = PF_INET;
  1232. child_ep->com.local_addr.sin_port = req->local_port;
  1233. child_ep->com.local_addr.sin_addr.s_addr = req->local_ip;
  1234. child_ep->com.remote_addr.sin_family = PF_INET;
  1235. child_ep->com.remote_addr.sin_port = req->peer_port;
  1236. child_ep->com.remote_addr.sin_addr.s_addr = req->peer_ip;
  1237. get_ep(&parent_ep->com);
  1238. child_ep->parent_ep = parent_ep;
  1239. child_ep->tos = G_PASS_OPEN_TOS(ntohl(req->tos_tid));
  1240. child_ep->l2t = l2t;
  1241. child_ep->dst = dst;
  1242. child_ep->hwtid = hwtid;
  1243. init_timer(&child_ep->timer);
  1244. cxgb3_insert_tid(tdev, &t3c_client, child_ep, hwtid);
  1245. accept_cr(child_ep, req->peer_ip, skb);
  1246. goto out;
  1247. reject:
  1248. reject_cr(tdev, hwtid, req->peer_ip, skb);
  1249. out:
  1250. return CPL_RET_BUF_DONE;
  1251. }
  1252. static int pass_establish(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
  1253. {
  1254. struct iwch_ep *ep = ctx;
  1255. struct cpl_pass_establish *req = cplhdr(skb);
  1256. PDBG("%s ep %p\n", __func__, ep);
  1257. ep->snd_seq = ntohl(req->snd_isn);
  1258. ep->rcv_seq = ntohl(req->rcv_isn);
  1259. set_emss(ep, ntohs(req->tcp_opt));
  1260. dst_confirm(ep->dst);
  1261. state_set(&ep->com, MPA_REQ_WAIT);
  1262. start_ep_timer(ep);
  1263. return CPL_RET_BUF_DONE;
  1264. }
  1265. static int peer_close(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
  1266. {
  1267. struct iwch_ep *ep = ctx;
  1268. struct iwch_qp_attributes attrs;
  1269. unsigned long flags;
  1270. int disconnect = 1;
  1271. int release = 0;
  1272. PDBG("%s ep %p\n", __func__, ep);
  1273. dst_confirm(ep->dst);
  1274. spin_lock_irqsave(&ep->com.lock, flags);
  1275. switch (ep->com.state) {
  1276. case MPA_REQ_WAIT:
  1277. __state_set(&ep->com, CLOSING);
  1278. break;
  1279. case MPA_REQ_SENT:
  1280. __state_set(&ep->com, CLOSING);
  1281. connect_reply_upcall(ep, -ECONNRESET);
  1282. break;
  1283. case MPA_REQ_RCVD:
  1284. /*
  1285. * We're gonna mark this puppy DEAD, but keep
  1286. * the reference on it until the ULP accepts or
  1287. * rejects the CR.
  1288. */
  1289. __state_set(&ep->com, CLOSING);
  1290. get_ep(&ep->com);
  1291. break;
  1292. case MPA_REP_SENT:
  1293. __state_set(&ep->com, CLOSING);
  1294. ep->com.rpl_done = 1;
  1295. ep->com.rpl_err = -ECONNRESET;
  1296. PDBG("waking up ep %p\n", ep);
  1297. wake_up(&ep->com.waitq);
  1298. break;
  1299. case FPDU_MODE:
  1300. start_ep_timer(ep);
  1301. __state_set(&ep->com, CLOSING);
  1302. attrs.next_state = IWCH_QP_STATE_CLOSING;
  1303. iwch_modify_qp(ep->com.qp->rhp, ep->com.qp,
  1304. IWCH_QP_ATTR_NEXT_STATE, &attrs, 1);
  1305. peer_close_upcall(ep);
  1306. break;
  1307. case ABORTING:
  1308. disconnect = 0;
  1309. break;
  1310. case CLOSING:
  1311. __state_set(&ep->com, MORIBUND);
  1312. disconnect = 0;
  1313. break;
  1314. case MORIBUND:
  1315. stop_ep_timer(ep);
  1316. if (ep->com.cm_id && ep->com.qp) {
  1317. attrs.next_state = IWCH_QP_STATE_IDLE;
  1318. iwch_modify_qp(ep->com.qp->rhp, ep->com.qp,
  1319. IWCH_QP_ATTR_NEXT_STATE, &attrs, 1);
  1320. }
  1321. close_complete_upcall(ep);
  1322. __state_set(&ep->com, DEAD);
  1323. release = 1;
  1324. disconnect = 0;
  1325. break;
  1326. case DEAD:
  1327. disconnect = 0;
  1328. break;
  1329. default:
  1330. BUG_ON(1);
  1331. }
  1332. spin_unlock_irqrestore(&ep->com.lock, flags);
  1333. if (disconnect)
  1334. iwch_ep_disconnect(ep, 0, GFP_KERNEL);
  1335. if (release)
  1336. release_ep_resources(ep);
  1337. return CPL_RET_BUF_DONE;
  1338. }
  1339. /*
  1340. * Returns whether an ABORT_REQ_RSS message is a negative advice.
  1341. */
  1342. static int is_neg_adv_abort(unsigned int status)
  1343. {
  1344. return status == CPL_ERR_RTX_NEG_ADVICE ||
  1345. status == CPL_ERR_PERSIST_NEG_ADVICE;
  1346. }
  1347. static int peer_abort(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
  1348. {
  1349. struct cpl_abort_req_rss *req = cplhdr(skb);
  1350. struct iwch_ep *ep = ctx;
  1351. struct cpl_abort_rpl *rpl;
  1352. struct sk_buff *rpl_skb;
  1353. struct iwch_qp_attributes attrs;
  1354. int ret;
  1355. int release = 0;
  1356. unsigned long flags;
  1357. if (is_neg_adv_abort(req->status)) {
  1358. PDBG("%s neg_adv_abort ep %p tid %d\n", __func__, ep,
  1359. ep->hwtid);
  1360. t3_l2t_send_event(ep->com.tdev, ep->l2t);
  1361. return CPL_RET_BUF_DONE;
  1362. }
  1363. /*
  1364. * We get 2 peer aborts from the HW. The first one must
  1365. * be ignored except for scribbling that we need one more.
  1366. */
  1367. if (!(ep->flags & PEER_ABORT_IN_PROGRESS)) {
  1368. ep->flags |= PEER_ABORT_IN_PROGRESS;
  1369. return CPL_RET_BUF_DONE;
  1370. }
  1371. spin_lock_irqsave(&ep->com.lock, flags);
  1372. PDBG("%s ep %p state %u\n", __func__, ep, ep->com.state);
  1373. switch (ep->com.state) {
  1374. case CONNECTING:
  1375. break;
  1376. case MPA_REQ_WAIT:
  1377. stop_ep_timer(ep);
  1378. break;
  1379. case MPA_REQ_SENT:
  1380. stop_ep_timer(ep);
  1381. connect_reply_upcall(ep, -ECONNRESET);
  1382. break;
  1383. case MPA_REP_SENT:
  1384. ep->com.rpl_done = 1;
  1385. ep->com.rpl_err = -ECONNRESET;
  1386. PDBG("waking up ep %p\n", ep);
  1387. wake_up(&ep->com.waitq);
  1388. break;
  1389. case MPA_REQ_RCVD:
  1390. /*
  1391. * We're gonna mark this puppy DEAD, but keep
  1392. * the reference on it until the ULP accepts or
  1393. * rejects the CR.
  1394. */
  1395. get_ep(&ep->com);
  1396. break;
  1397. case MORIBUND:
  1398. case CLOSING:
  1399. stop_ep_timer(ep);
  1400. /*FALLTHROUGH*/
  1401. case FPDU_MODE:
  1402. if (ep->com.cm_id && ep->com.qp) {
  1403. attrs.next_state = IWCH_QP_STATE_ERROR;
  1404. ret = iwch_modify_qp(ep->com.qp->rhp,
  1405. ep->com.qp, IWCH_QP_ATTR_NEXT_STATE,
  1406. &attrs, 1);
  1407. if (ret)
  1408. printk(KERN_ERR MOD
  1409. "%s - qp <- error failed!\n",
  1410. __func__);
  1411. }
  1412. peer_abort_upcall(ep);
  1413. break;
  1414. case ABORTING:
  1415. break;
  1416. case DEAD:
  1417. PDBG("%s PEER_ABORT IN DEAD STATE!!!!\n", __func__);
  1418. spin_unlock_irqrestore(&ep->com.lock, flags);
  1419. return CPL_RET_BUF_DONE;
  1420. default:
  1421. BUG_ON(1);
  1422. break;
  1423. }
  1424. dst_confirm(ep->dst);
  1425. if (ep->com.state != ABORTING) {
  1426. __state_set(&ep->com, DEAD);
  1427. release = 1;
  1428. }
  1429. spin_unlock_irqrestore(&ep->com.lock, flags);
  1430. rpl_skb = get_skb(skb, sizeof(*rpl), GFP_KERNEL);
  1431. if (!rpl_skb) {
  1432. printk(KERN_ERR MOD "%s - cannot allocate skb!\n",
  1433. __func__);
  1434. release = 1;
  1435. goto out;
  1436. }
  1437. rpl_skb->priority = CPL_PRIORITY_DATA;
  1438. rpl = (struct cpl_abort_rpl *) skb_put(rpl_skb, sizeof(*rpl));
  1439. rpl->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_HOST_ABORT_CON_RPL));
  1440. rpl->wr.wr_lo = htonl(V_WR_TID(ep->hwtid));
  1441. OPCODE_TID(rpl) = htonl(MK_OPCODE_TID(CPL_ABORT_RPL, ep->hwtid));
  1442. rpl->cmd = CPL_ABORT_NO_RST;
  1443. iwch_cxgb3_ofld_send(ep->com.tdev, rpl_skb);
  1444. out:
  1445. if (release)
  1446. release_ep_resources(ep);
  1447. return CPL_RET_BUF_DONE;
  1448. }
  1449. static int close_con_rpl(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
  1450. {
  1451. struct iwch_ep *ep = ctx;
  1452. struct iwch_qp_attributes attrs;
  1453. unsigned long flags;
  1454. int release = 0;
  1455. PDBG("%s ep %p\n", __func__, ep);
  1456. BUG_ON(!ep);
  1457. /* The cm_id may be null if we failed to connect */
  1458. spin_lock_irqsave(&ep->com.lock, flags);
  1459. switch (ep->com.state) {
  1460. case CLOSING:
  1461. __state_set(&ep->com, MORIBUND);
  1462. break;
  1463. case MORIBUND:
  1464. stop_ep_timer(ep);
  1465. if ((ep->com.cm_id) && (ep->com.qp)) {
  1466. attrs.next_state = IWCH_QP_STATE_IDLE;
  1467. iwch_modify_qp(ep->com.qp->rhp,
  1468. ep->com.qp,
  1469. IWCH_QP_ATTR_NEXT_STATE,
  1470. &attrs, 1);
  1471. }
  1472. close_complete_upcall(ep);
  1473. __state_set(&ep->com, DEAD);
  1474. release = 1;
  1475. break;
  1476. case ABORTING:
  1477. case DEAD:
  1478. break;
  1479. default:
  1480. BUG_ON(1);
  1481. break;
  1482. }
  1483. spin_unlock_irqrestore(&ep->com.lock, flags);
  1484. if (release)
  1485. release_ep_resources(ep);
  1486. return CPL_RET_BUF_DONE;
  1487. }
  1488. /*
  1489. * T3A does 3 things when a TERM is received:
  1490. * 1) send up a CPL_RDMA_TERMINATE message with the TERM packet
  1491. * 2) generate an async event on the QP with the TERMINATE opcode
  1492. * 3) post a TERMINATE opcde cqe into the associated CQ.
  1493. *
  1494. * For (1), we save the message in the qp for later consumer consumption.
  1495. * For (2), we move the QP into TERMINATE, post a QP event and disconnect.
  1496. * For (3), we toss the CQE in cxio_poll_cq().
  1497. *
  1498. * terminate() handles case (1)...
  1499. */
  1500. static int terminate(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
  1501. {
  1502. struct iwch_ep *ep = ctx;
  1503. if (state_read(&ep->com) != FPDU_MODE)
  1504. return CPL_RET_BUF_DONE;
  1505. PDBG("%s ep %p\n", __func__, ep);
  1506. skb_pull(skb, sizeof(struct cpl_rdma_terminate));
  1507. PDBG("%s saving %d bytes of term msg\n", __func__, skb->len);
  1508. skb_copy_from_linear_data(skb, ep->com.qp->attr.terminate_buffer,
  1509. skb->len);
  1510. ep->com.qp->attr.terminate_msg_len = skb->len;
  1511. ep->com.qp->attr.is_terminate_local = 0;
  1512. return CPL_RET_BUF_DONE;
  1513. }
  1514. static int ec_status(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
  1515. {
  1516. struct cpl_rdma_ec_status *rep = cplhdr(skb);
  1517. struct iwch_ep *ep = ctx;
  1518. PDBG("%s ep %p tid %u status %d\n", __func__, ep, ep->hwtid,
  1519. rep->status);
  1520. if (rep->status) {
  1521. struct iwch_qp_attributes attrs;
  1522. printk(KERN_ERR MOD "%s BAD CLOSE - Aborting tid %u\n",
  1523. __func__, ep->hwtid);
  1524. stop_ep_timer(ep);
  1525. attrs.next_state = IWCH_QP_STATE_ERROR;
  1526. iwch_modify_qp(ep->com.qp->rhp,
  1527. ep->com.qp, IWCH_QP_ATTR_NEXT_STATE,
  1528. &attrs, 1);
  1529. abort_connection(ep, NULL, GFP_KERNEL);
  1530. }
  1531. return CPL_RET_BUF_DONE;
  1532. }
  1533. static void ep_timeout(unsigned long arg)
  1534. {
  1535. struct iwch_ep *ep = (struct iwch_ep *)arg;
  1536. struct iwch_qp_attributes attrs;
  1537. unsigned long flags;
  1538. int abort = 1;
  1539. spin_lock_irqsave(&ep->com.lock, flags);
  1540. PDBG("%s ep %p tid %u state %d\n", __func__, ep, ep->hwtid,
  1541. ep->com.state);
  1542. switch (ep->com.state) {
  1543. case MPA_REQ_SENT:
  1544. __state_set(&ep->com, ABORTING);
  1545. connect_reply_upcall(ep, -ETIMEDOUT);
  1546. break;
  1547. case MPA_REQ_WAIT:
  1548. __state_set(&ep->com, ABORTING);
  1549. break;
  1550. case CLOSING:
  1551. case MORIBUND:
  1552. if (ep->com.cm_id && ep->com.qp) {
  1553. attrs.next_state = IWCH_QP_STATE_ERROR;
  1554. iwch_modify_qp(ep->com.qp->rhp,
  1555. ep->com.qp, IWCH_QP_ATTR_NEXT_STATE,
  1556. &attrs, 1);
  1557. }
  1558. __state_set(&ep->com, ABORTING);
  1559. break;
  1560. default:
  1561. printk(KERN_ERR "%s unexpected state ep %p state %u\n",
  1562. __func__, ep, ep->com.state);
  1563. WARN_ON(1);
  1564. abort = 0;
  1565. }
  1566. spin_unlock_irqrestore(&ep->com.lock, flags);
  1567. if (abort)
  1568. abort_connection(ep, NULL, GFP_ATOMIC);
  1569. put_ep(&ep->com);
  1570. }
  1571. int iwch_reject_cr(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
  1572. {
  1573. int err;
  1574. struct iwch_ep *ep = to_ep(cm_id);
  1575. PDBG("%s ep %p tid %u\n", __func__, ep, ep->hwtid);
  1576. if (state_read(&ep->com) == DEAD) {
  1577. put_ep(&ep->com);
  1578. return -ECONNRESET;
  1579. }
  1580. BUG_ON(state_read(&ep->com) != MPA_REQ_RCVD);
  1581. if (mpa_rev == 0)
  1582. abort_connection(ep, NULL, GFP_KERNEL);
  1583. else {
  1584. err = send_mpa_reject(ep, pdata, pdata_len);
  1585. err = iwch_ep_disconnect(ep, 0, GFP_KERNEL);
  1586. }
  1587. return 0;
  1588. }
  1589. int iwch_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
  1590. {
  1591. int err;
  1592. struct iwch_qp_attributes attrs;
  1593. enum iwch_qp_attr_mask mask;
  1594. struct iwch_ep *ep = to_ep(cm_id);
  1595. struct iwch_dev *h = to_iwch_dev(cm_id->device);
  1596. struct iwch_qp *qp = get_qhp(h, conn_param->qpn);
  1597. PDBG("%s ep %p tid %u\n", __func__, ep, ep->hwtid);
  1598. if (state_read(&ep->com) == DEAD)
  1599. return -ECONNRESET;
  1600. BUG_ON(state_read(&ep->com) != MPA_REQ_RCVD);
  1601. BUG_ON(!qp);
  1602. if ((conn_param->ord > qp->rhp->attr.max_rdma_read_qp_depth) ||
  1603. (conn_param->ird > qp->rhp->attr.max_rdma_reads_per_qp)) {
  1604. abort_connection(ep, NULL, GFP_KERNEL);
  1605. return -EINVAL;
  1606. }
  1607. cm_id->add_ref(cm_id);
  1608. ep->com.cm_id = cm_id;
  1609. ep->com.qp = qp;
  1610. ep->com.rpl_done = 0;
  1611. ep->com.rpl_err = 0;
  1612. ep->ird = conn_param->ird;
  1613. ep->ord = conn_param->ord;
  1614. PDBG("%s %d ird %d ord %d\n", __func__, __LINE__, ep->ird, ep->ord);
  1615. get_ep(&ep->com);
  1616. /* bind QP to EP and move to RTS */
  1617. attrs.mpa_attr = ep->mpa_attr;
  1618. attrs.max_ird = ep->ird;
  1619. attrs.max_ord = ep->ord;
  1620. attrs.llp_stream_handle = ep;
  1621. attrs.next_state = IWCH_QP_STATE_RTS;
  1622. /* bind QP and TID with INIT_WR */
  1623. mask = IWCH_QP_ATTR_NEXT_STATE |
  1624. IWCH_QP_ATTR_LLP_STREAM_HANDLE |
  1625. IWCH_QP_ATTR_MPA_ATTR |
  1626. IWCH_QP_ATTR_MAX_IRD |
  1627. IWCH_QP_ATTR_MAX_ORD;
  1628. err = iwch_modify_qp(ep->com.qp->rhp,
  1629. ep->com.qp, mask, &attrs, 1);
  1630. if (err)
  1631. goto err;
  1632. /* if needed, wait for wr_ack */
  1633. if (iwch_rqes_posted(qp)) {
  1634. wait_event(ep->com.waitq, ep->com.rpl_done);
  1635. err = ep->com.rpl_err;
  1636. if (err)
  1637. goto err;
  1638. }
  1639. err = send_mpa_reply(ep, conn_param->private_data,
  1640. conn_param->private_data_len);
  1641. if (err)
  1642. goto err;
  1643. state_set(&ep->com, FPDU_MODE);
  1644. established_upcall(ep);
  1645. put_ep(&ep->com);
  1646. return 0;
  1647. err:
  1648. ep->com.cm_id = NULL;
  1649. ep->com.qp = NULL;
  1650. cm_id->rem_ref(cm_id);
  1651. put_ep(&ep->com);
  1652. return err;
  1653. }
  1654. static int is_loopback_dst(struct iw_cm_id *cm_id)
  1655. {
  1656. struct net_device *dev;
  1657. dev = ip_dev_find(&init_net, cm_id->remote_addr.sin_addr.s_addr);
  1658. if (!dev)
  1659. return 0;
  1660. dev_put(dev);
  1661. return 1;
  1662. }
  1663. int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
  1664. {
  1665. int err = 0;
  1666. struct iwch_dev *h = to_iwch_dev(cm_id->device);
  1667. struct iwch_ep *ep;
  1668. struct rtable *rt;
  1669. if (is_loopback_dst(cm_id)) {
  1670. err = -ENOSYS;
  1671. goto out;
  1672. }
  1673. ep = alloc_ep(sizeof(*ep), GFP_KERNEL);
  1674. if (!ep) {
  1675. printk(KERN_ERR MOD "%s - cannot alloc ep.\n", __func__);
  1676. err = -ENOMEM;
  1677. goto out;
  1678. }
  1679. init_timer(&ep->timer);
  1680. ep->plen = conn_param->private_data_len;
  1681. if (ep->plen)
  1682. memcpy(ep->mpa_pkt + sizeof(struct mpa_message),
  1683. conn_param->private_data, ep->plen);
  1684. ep->ird = conn_param->ird;
  1685. ep->ord = conn_param->ord;
  1686. ep->com.tdev = h->rdev.t3cdev_p;
  1687. cm_id->add_ref(cm_id);
  1688. ep->com.cm_id = cm_id;
  1689. ep->com.qp = get_qhp(h, conn_param->qpn);
  1690. BUG_ON(!ep->com.qp);
  1691. PDBG("%s qpn 0x%x qp %p cm_id %p\n", __func__, conn_param->qpn,
  1692. ep->com.qp, cm_id);
  1693. /*
  1694. * Allocate an active TID to initiate a TCP connection.
  1695. */
  1696. ep->atid = cxgb3_alloc_atid(h->rdev.t3cdev_p, &t3c_client, ep);
  1697. if (ep->atid == -1) {
  1698. printk(KERN_ERR MOD "%s - cannot alloc atid.\n", __func__);
  1699. err = -ENOMEM;
  1700. goto fail2;
  1701. }
  1702. /* find a route */
  1703. rt = find_route(h->rdev.t3cdev_p,
  1704. cm_id->local_addr.sin_addr.s_addr,
  1705. cm_id->remote_addr.sin_addr.s_addr,
  1706. cm_id->local_addr.sin_port,
  1707. cm_id->remote_addr.sin_port, IPTOS_LOWDELAY);
  1708. if (!rt) {
  1709. printk(KERN_ERR MOD "%s - cannot find route.\n", __func__);
  1710. err = -EHOSTUNREACH;
  1711. goto fail3;
  1712. }
  1713. ep->dst = &rt->u.dst;
  1714. /* get a l2t entry */
  1715. ep->l2t = t3_l2t_get(ep->com.tdev, ep->dst->neighbour,
  1716. ep->dst->neighbour->dev);
  1717. if (!ep->l2t) {
  1718. printk(KERN_ERR MOD "%s - cannot alloc l2e.\n", __func__);
  1719. err = -ENOMEM;
  1720. goto fail4;
  1721. }
  1722. state_set(&ep->com, CONNECTING);
  1723. ep->tos = IPTOS_LOWDELAY;
  1724. ep->com.local_addr = cm_id->local_addr;
  1725. ep->com.remote_addr = cm_id->remote_addr;
  1726. /* send connect request to rnic */
  1727. err = send_connect(ep);
  1728. if (!err)
  1729. goto out;
  1730. l2t_release(L2DATA(h->rdev.t3cdev_p), ep->l2t);
  1731. fail4:
  1732. dst_release(ep->dst);
  1733. fail3:
  1734. cxgb3_free_atid(ep->com.tdev, ep->atid);
  1735. fail2:
  1736. cm_id->rem_ref(cm_id);
  1737. put_ep(&ep->com);
  1738. out:
  1739. return err;
  1740. }
  1741. int iwch_create_listen(struct iw_cm_id *cm_id, int backlog)
  1742. {
  1743. int err = 0;
  1744. struct iwch_dev *h = to_iwch_dev(cm_id->device);
  1745. struct iwch_listen_ep *ep;
  1746. might_sleep();
  1747. ep = alloc_ep(sizeof(*ep), GFP_KERNEL);
  1748. if (!ep) {
  1749. printk(KERN_ERR MOD "%s - cannot alloc ep.\n", __func__);
  1750. err = -ENOMEM;
  1751. goto fail1;
  1752. }
  1753. PDBG("%s ep %p\n", __func__, ep);
  1754. ep->com.tdev = h->rdev.t3cdev_p;
  1755. cm_id->add_ref(cm_id);
  1756. ep->com.cm_id = cm_id;
  1757. ep->backlog = backlog;
  1758. ep->com.local_addr = cm_id->local_addr;
  1759. /*
  1760. * Allocate a server TID.
  1761. */
  1762. ep->stid = cxgb3_alloc_stid(h->rdev.t3cdev_p, &t3c_client, ep);
  1763. if (ep->stid == -1) {
  1764. printk(KERN_ERR MOD "%s - cannot alloc atid.\n", __func__);
  1765. err = -ENOMEM;
  1766. goto fail2;
  1767. }
  1768. state_set(&ep->com, LISTEN);
  1769. err = listen_start(ep);
  1770. if (err)
  1771. goto fail3;
  1772. /* wait for pass_open_rpl */
  1773. wait_event(ep->com.waitq, ep->com.rpl_done);
  1774. err = ep->com.rpl_err;
  1775. if (!err) {
  1776. cm_id->provider_data = ep;
  1777. goto out;
  1778. }
  1779. fail3:
  1780. cxgb3_free_stid(ep->com.tdev, ep->stid);
  1781. fail2:
  1782. cm_id->rem_ref(cm_id);
  1783. put_ep(&ep->com);
  1784. fail1:
  1785. out:
  1786. return err;
  1787. }
  1788. int iwch_destroy_listen(struct iw_cm_id *cm_id)
  1789. {
  1790. int err;
  1791. struct iwch_listen_ep *ep = to_listen_ep(cm_id);
  1792. PDBG("%s ep %p\n", __func__, ep);
  1793. might_sleep();
  1794. state_set(&ep->com, DEAD);
  1795. ep->com.rpl_done = 0;
  1796. ep->com.rpl_err = 0;
  1797. err = listen_stop(ep);
  1798. if (err)
  1799. goto done;
  1800. wait_event(ep->com.waitq, ep->com.rpl_done);
  1801. cxgb3_free_stid(ep->com.tdev, ep->stid);
  1802. done:
  1803. err = ep->com.rpl_err;
  1804. cm_id->rem_ref(cm_id);
  1805. put_ep(&ep->com);
  1806. return err;
  1807. }
  1808. int iwch_ep_disconnect(struct iwch_ep *ep, int abrupt, gfp_t gfp)
  1809. {
  1810. int ret=0;
  1811. unsigned long flags;
  1812. int close = 0;
  1813. int fatal = 0;
  1814. struct t3cdev *tdev;
  1815. struct cxio_rdev *rdev;
  1816. spin_lock_irqsave(&ep->com.lock, flags);
  1817. PDBG("%s ep %p state %s, abrupt %d\n", __func__, ep,
  1818. states[ep->com.state], abrupt);
  1819. tdev = (struct t3cdev *)ep->com.tdev;
  1820. rdev = (struct cxio_rdev *)tdev->ulp;
  1821. if (cxio_fatal_error(rdev)) {
  1822. fatal = 1;
  1823. close_complete_upcall(ep);
  1824. ep->com.state = DEAD;
  1825. }
  1826. switch (ep->com.state) {
  1827. case MPA_REQ_WAIT:
  1828. case MPA_REQ_SENT:
  1829. case MPA_REQ_RCVD:
  1830. case MPA_REP_SENT:
  1831. case FPDU_MODE:
  1832. close = 1;
  1833. if (abrupt)
  1834. ep->com.state = ABORTING;
  1835. else {
  1836. ep->com.state = CLOSING;
  1837. start_ep_timer(ep);
  1838. }
  1839. break;
  1840. case CLOSING:
  1841. close = 1;
  1842. if (abrupt) {
  1843. stop_ep_timer(ep);
  1844. ep->com.state = ABORTING;
  1845. } else
  1846. ep->com.state = MORIBUND;
  1847. break;
  1848. case MORIBUND:
  1849. case ABORTING:
  1850. case DEAD:
  1851. PDBG("%s ignoring disconnect ep %p state %u\n",
  1852. __func__, ep, ep->com.state);
  1853. break;
  1854. default:
  1855. BUG();
  1856. break;
  1857. }
  1858. spin_unlock_irqrestore(&ep->com.lock, flags);
  1859. if (close) {
  1860. if (abrupt)
  1861. ret = send_abort(ep, NULL, gfp);
  1862. else
  1863. ret = send_halfclose(ep, gfp);
  1864. if (ret)
  1865. fatal = 1;
  1866. }
  1867. if (fatal)
  1868. release_ep_resources(ep);
  1869. return ret;
  1870. }
  1871. int iwch_ep_redirect(void *ctx, struct dst_entry *old, struct dst_entry *new,
  1872. struct l2t_entry *l2t)
  1873. {
  1874. struct iwch_ep *ep = ctx;
  1875. if (ep->dst != old)
  1876. return 0;
  1877. PDBG("%s ep %p redirect to dst %p l2t %p\n", __func__, ep, new,
  1878. l2t);
  1879. dst_hold(new);
  1880. l2t_release(L2DATA(ep->com.tdev), ep->l2t);
  1881. ep->l2t = l2t;
  1882. dst_release(old);
  1883. ep->dst = new;
  1884. return 1;
  1885. }
  1886. /*
  1887. * All the CM events are handled on a work queue to have a safe context.
  1888. */
  1889. static int sched(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
  1890. {
  1891. struct iwch_ep_common *epc = ctx;
  1892. get_ep(epc);
  1893. /*
  1894. * Save ctx and tdev in the skb->cb area.
  1895. */
  1896. *((void **) skb->cb) = ctx;
  1897. *((struct t3cdev **) (skb->cb + sizeof(void *))) = tdev;
  1898. /*
  1899. * Queue the skb and schedule the worker thread.
  1900. */
  1901. skb_queue_tail(&rxq, skb);
  1902. queue_work(workq, &skb_work);
  1903. return 0;
  1904. }
  1905. static int set_tcb_rpl(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
  1906. {
  1907. struct cpl_set_tcb_rpl *rpl = cplhdr(skb);
  1908. if (rpl->status != CPL_ERR_NONE) {
  1909. printk(KERN_ERR MOD "Unexpected SET_TCB_RPL status %u "
  1910. "for tid %u\n", rpl->status, GET_TID(rpl));
  1911. }
  1912. return CPL_RET_BUF_DONE;
  1913. }
  1914. int __init iwch_cm_init(void)
  1915. {
  1916. skb_queue_head_init(&rxq);
  1917. workq = create_singlethread_workqueue("iw_cxgb3");
  1918. if (!workq)
  1919. return -ENOMEM;
  1920. /*
  1921. * All upcalls from the T3 Core go to sched() to
  1922. * schedule the processing on a work queue.
  1923. */
  1924. t3c_handlers[CPL_ACT_ESTABLISH] = sched;
  1925. t3c_handlers[CPL_ACT_OPEN_RPL] = sched;
  1926. t3c_handlers[CPL_RX_DATA] = sched;
  1927. t3c_handlers[CPL_TX_DMA_ACK] = sched;
  1928. t3c_handlers[CPL_ABORT_RPL_RSS] = sched;
  1929. t3c_handlers[CPL_ABORT_RPL] = sched;
  1930. t3c_handlers[CPL_PASS_OPEN_RPL] = sched;
  1931. t3c_handlers[CPL_CLOSE_LISTSRV_RPL] = sched;
  1932. t3c_handlers[CPL_PASS_ACCEPT_REQ] = sched;
  1933. t3c_handlers[CPL_PASS_ESTABLISH] = sched;
  1934. t3c_handlers[CPL_PEER_CLOSE] = sched;
  1935. t3c_handlers[CPL_CLOSE_CON_RPL] = sched;
  1936. t3c_handlers[CPL_ABORT_REQ_RSS] = sched;
  1937. t3c_handlers[CPL_RDMA_TERMINATE] = sched;
  1938. t3c_handlers[CPL_RDMA_EC_STATUS] = sched;
  1939. t3c_handlers[CPL_SET_TCB_RPL] = set_tcb_rpl;
  1940. /*
  1941. * These are the real handlers that are called from a
  1942. * work queue.
  1943. */
  1944. work_handlers[CPL_ACT_ESTABLISH] = act_establish;
  1945. work_handlers[CPL_ACT_OPEN_RPL] = act_open_rpl;
  1946. work_handlers[CPL_RX_DATA] = rx_data;
  1947. work_handlers[CPL_TX_DMA_ACK] = tx_ack;
  1948. work_handlers[CPL_ABORT_RPL_RSS] = abort_rpl;
  1949. work_handlers[CPL_ABORT_RPL] = abort_rpl;
  1950. work_handlers[CPL_PASS_OPEN_RPL] = pass_open_rpl;
  1951. work_handlers[CPL_CLOSE_LISTSRV_RPL] = close_listsrv_rpl;
  1952. work_handlers[CPL_PASS_ACCEPT_REQ] = pass_accept_req;
  1953. work_handlers[CPL_PASS_ESTABLISH] = pass_establish;
  1954. work_handlers[CPL_PEER_CLOSE] = peer_close;
  1955. work_handlers[CPL_ABORT_REQ_RSS] = peer_abort;
  1956. work_handlers[CPL_CLOSE_CON_RPL] = close_con_rpl;
  1957. work_handlers[CPL_RDMA_TERMINATE] = terminate;
  1958. work_handlers[CPL_RDMA_EC_STATUS] = ec_status;
  1959. return 0;
  1960. }
  1961. void __exit iwch_cm_term(void)
  1962. {
  1963. flush_workqueue(workq);
  1964. destroy_workqueue(workq);
  1965. }