qeth_l2_main.c 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160
  1. /*
  2. * Copyright IBM Corp. 2007, 2009
  3. * Author(s): Utz Bacher <utz.bacher@de.ibm.com>,
  4. * Frank Pavlic <fpavlic@de.ibm.com>,
  5. * Thomas Spatzier <tspat@de.ibm.com>,
  6. * Frank Blaschka <frank.blaschka@de.ibm.com>
  7. */
  8. #define KMSG_COMPONENT "qeth"
  9. #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
  10. #include <linux/module.h>
  11. #include <linux/moduleparam.h>
  12. #include <linux/string.h>
  13. #include <linux/errno.h>
  14. #include <linux/kernel.h>
  15. #include <linux/slab.h>
  16. #include <linux/etherdevice.h>
  17. #include <linux/mii.h>
  18. #include <linux/ip.h>
  19. #include <linux/list.h>
  20. #include <linux/hash.h>
  21. #include <linux/hashtable.h>
  22. #include <linux/string.h>
  23. #include "qeth_core.h"
  24. #include "qeth_l2.h"
  25. static int qeth_l2_set_offline(struct ccwgroup_device *);
  26. static int qeth_l2_stop(struct net_device *);
  27. static int qeth_l2_send_delmac(struct qeth_card *, __u8 *);
  28. static int qeth_l2_send_setdelmac(struct qeth_card *, __u8 *,
  29. enum qeth_ipa_cmds);
  30. static void qeth_l2_set_rx_mode(struct net_device *);
  31. static int qeth_l2_recover(void *);
  32. static void qeth_bridgeport_query_support(struct qeth_card *card);
  33. static void qeth_bridge_state_change(struct qeth_card *card,
  34. struct qeth_ipa_cmd *cmd);
  35. static void qeth_bridge_host_event(struct qeth_card *card,
  36. struct qeth_ipa_cmd *cmd);
  37. static int qeth_l2_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
  38. {
  39. struct qeth_card *card = dev->ml_priv;
  40. struct mii_ioctl_data *mii_data;
  41. int rc = 0;
  42. if (!card)
  43. return -ENODEV;
  44. if (!qeth_card_hw_is_reachable(card))
  45. return -ENODEV;
  46. if (card->info.type == QETH_CARD_TYPE_OSN)
  47. return -EPERM;
  48. switch (cmd) {
  49. case SIOC_QETH_ADP_SET_SNMP_CONTROL:
  50. rc = qeth_snmp_command(card, rq->ifr_ifru.ifru_data);
  51. break;
  52. case SIOC_QETH_GET_CARD_TYPE:
  53. if ((card->info.type == QETH_CARD_TYPE_OSD ||
  54. card->info.type == QETH_CARD_TYPE_OSM ||
  55. card->info.type == QETH_CARD_TYPE_OSX) &&
  56. !card->info.guestlan)
  57. return 1;
  58. return 0;
  59. break;
  60. case SIOCGMIIPHY:
  61. mii_data = if_mii(rq);
  62. mii_data->phy_id = 0;
  63. break;
  64. case SIOCGMIIREG:
  65. mii_data = if_mii(rq);
  66. if (mii_data->phy_id != 0)
  67. rc = -EINVAL;
  68. else
  69. mii_data->val_out = qeth_mdio_read(dev,
  70. mii_data->phy_id, mii_data->reg_num);
  71. break;
  72. case SIOC_QETH_QUERY_OAT:
  73. rc = qeth_query_oat_command(card, rq->ifr_ifru.ifru_data);
  74. break;
  75. default:
  76. rc = -EOPNOTSUPP;
  77. }
  78. if (rc)
  79. QETH_CARD_TEXT_(card, 2, "ioce%d", rc);
  80. return rc;
  81. }
  82. static int qeth_l2_verify_dev(struct net_device *dev)
  83. {
  84. struct qeth_card *card;
  85. unsigned long flags;
  86. int rc = 0;
  87. read_lock_irqsave(&qeth_core_card_list.rwlock, flags);
  88. list_for_each_entry(card, &qeth_core_card_list.list, list) {
  89. if (card->dev == dev) {
  90. rc = QETH_REAL_CARD;
  91. break;
  92. }
  93. }
  94. read_unlock_irqrestore(&qeth_core_card_list.rwlock, flags);
  95. return rc;
  96. }
  97. static struct net_device *qeth_l2_netdev_by_devno(unsigned char *read_dev_no)
  98. {
  99. struct qeth_card *card;
  100. struct net_device *ndev;
  101. __u16 temp_dev_no;
  102. unsigned long flags;
  103. struct ccw_dev_id read_devid;
  104. ndev = NULL;
  105. memcpy(&temp_dev_no, read_dev_no, 2);
  106. read_lock_irqsave(&qeth_core_card_list.rwlock, flags);
  107. list_for_each_entry(card, &qeth_core_card_list.list, list) {
  108. ccw_device_get_id(CARD_RDEV(card), &read_devid);
  109. if (read_devid.devno == temp_dev_no) {
  110. ndev = card->dev;
  111. break;
  112. }
  113. }
  114. read_unlock_irqrestore(&qeth_core_card_list.rwlock, flags);
  115. return ndev;
  116. }
  117. static int qeth_setdel_makerc(struct qeth_card *card, int retcode)
  118. {
  119. int rc;
  120. if (retcode)
  121. QETH_CARD_TEXT_(card, 2, "err%04x", retcode);
  122. switch (retcode) {
  123. case IPA_RC_SUCCESS:
  124. rc = 0;
  125. break;
  126. case IPA_RC_L2_UNSUPPORTED_CMD:
  127. rc = -EOPNOTSUPP;
  128. break;
  129. case IPA_RC_L2_ADDR_TABLE_FULL:
  130. rc = -ENOSPC;
  131. break;
  132. case IPA_RC_L2_DUP_MAC:
  133. case IPA_RC_L2_DUP_LAYER3_MAC:
  134. rc = -EEXIST;
  135. break;
  136. case IPA_RC_L2_MAC_NOT_AUTH_BY_HYP:
  137. case IPA_RC_L2_MAC_NOT_AUTH_BY_ADP:
  138. rc = -EPERM;
  139. break;
  140. case IPA_RC_L2_MAC_NOT_FOUND:
  141. rc = -ENOENT;
  142. break;
  143. case -ENOMEM:
  144. rc = -ENOMEM;
  145. break;
  146. default:
  147. rc = -EIO;
  148. break;
  149. }
  150. return rc;
  151. }
  152. static int qeth_l2_send_setgroupmac(struct qeth_card *card, __u8 *mac)
  153. {
  154. int rc;
  155. QETH_CARD_TEXT(card, 2, "L2Sgmac");
  156. rc = qeth_setdel_makerc(card, qeth_l2_send_setdelmac(card, mac,
  157. IPA_CMD_SETGMAC));
  158. if (rc == -EEXIST)
  159. QETH_DBF_MESSAGE(2, "Group MAC %pM already existing on %s\n",
  160. mac, QETH_CARD_IFNAME(card));
  161. else if (rc)
  162. QETH_DBF_MESSAGE(2, "Could not set group MAC %pM on %s: %d\n",
  163. mac, QETH_CARD_IFNAME(card), rc);
  164. return rc;
  165. }
  166. static int qeth_l2_send_delgroupmac(struct qeth_card *card, __u8 *mac)
  167. {
  168. int rc;
  169. QETH_CARD_TEXT(card, 2, "L2Dgmac");
  170. rc = qeth_setdel_makerc(card, qeth_l2_send_setdelmac(card, mac,
  171. IPA_CMD_DELGMAC));
  172. if (rc)
  173. QETH_DBF_MESSAGE(2,
  174. "Could not delete group MAC %pM on %s: %d\n",
  175. mac, QETH_CARD_IFNAME(card), rc);
  176. return rc;
  177. }
  178. static inline u32 qeth_l2_mac_hash(const u8 *addr)
  179. {
  180. return get_unaligned((u32 *)(&addr[2]));
  181. }
  182. static int qeth_l2_write_mac(struct qeth_card *card, struct qeth_mac *mac)
  183. {
  184. int rc;
  185. if (mac->is_uc) {
  186. rc = qeth_setdel_makerc(card,
  187. qeth_l2_send_setdelmac(card, mac->mac_addr,
  188. IPA_CMD_SETVMAC));
  189. } else {
  190. rc = qeth_setdel_makerc(card,
  191. qeth_l2_send_setgroupmac(card, mac->mac_addr));
  192. }
  193. return rc;
  194. }
  195. static void qeth_l2_del_all_macs(struct qeth_card *card, int del)
  196. {
  197. struct qeth_mac *mac;
  198. struct hlist_node *tmp;
  199. int i;
  200. spin_lock_bh(&card->mclock);
  201. hash_for_each_safe(card->mac_htable, i, tmp, mac, hnode) {
  202. if (del) {
  203. if (mac->is_uc)
  204. qeth_l2_send_setdelmac(card, mac->mac_addr,
  205. IPA_CMD_DELVMAC);
  206. else
  207. qeth_l2_send_delgroupmac(card, mac->mac_addr);
  208. }
  209. hash_del(&mac->hnode);
  210. kfree(mac);
  211. }
  212. spin_unlock_bh(&card->mclock);
  213. }
  214. static inline int qeth_l2_get_cast_type(struct qeth_card *card,
  215. struct sk_buff *skb)
  216. {
  217. if (card->info.type == QETH_CARD_TYPE_OSN)
  218. return RTN_UNSPEC;
  219. if (is_broadcast_ether_addr(skb->data))
  220. return RTN_BROADCAST;
  221. if (is_multicast_ether_addr(skb->data))
  222. return RTN_MULTICAST;
  223. return RTN_UNSPEC;
  224. }
  225. static inline void qeth_l2_hdr_csum(struct qeth_card *card,
  226. struct qeth_hdr *hdr, struct sk_buff *skb)
  227. {
  228. struct iphdr *iph = ip_hdr(skb);
  229. /* tcph->check contains already the pseudo hdr checksum
  230. * so just set the header flags
  231. */
  232. if (iph->protocol == IPPROTO_UDP)
  233. hdr->hdr.l2.flags[1] |= QETH_HDR_EXT_UDP;
  234. hdr->hdr.l2.flags[1] |= QETH_HDR_EXT_CSUM_TRANSP_REQ |
  235. QETH_HDR_EXT_CSUM_HDR_REQ;
  236. iph->check = 0;
  237. if (card->options.performance_stats)
  238. card->perf_stats.tx_csum++;
  239. }
  240. static void qeth_l2_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
  241. struct sk_buff *skb, int cast_type)
  242. {
  243. struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb_mac_header(skb);
  244. memset(hdr, 0, sizeof(struct qeth_hdr));
  245. hdr->hdr.l2.id = QETH_HEADER_TYPE_LAYER2;
  246. /* set byte byte 3 to casting flags */
  247. if (cast_type == RTN_MULTICAST)
  248. hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_MULTICAST;
  249. else if (cast_type == RTN_BROADCAST)
  250. hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_BROADCAST;
  251. else
  252. hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_UNICAST;
  253. hdr->hdr.l2.pkt_length = skb->len-QETH_HEADER_SIZE;
  254. /* VSWITCH relies on the VLAN
  255. * information to be present in
  256. * the QDIO header */
  257. if (veth->h_vlan_proto == __constant_htons(ETH_P_8021Q)) {
  258. hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_VLAN;
  259. hdr->hdr.l2.vlan_id = ntohs(veth->h_vlan_TCI);
  260. }
  261. }
  262. static int qeth_l2_send_setdelvlan_cb(struct qeth_card *card,
  263. struct qeth_reply *reply, unsigned long data)
  264. {
  265. struct qeth_ipa_cmd *cmd;
  266. QETH_CARD_TEXT(card, 2, "L2sdvcb");
  267. cmd = (struct qeth_ipa_cmd *) data;
  268. if (cmd->hdr.return_code) {
  269. QETH_DBF_MESSAGE(2, "Error in processing VLAN %i on %s: 0x%x. "
  270. "Continuing\n", cmd->data.setdelvlan.vlan_id,
  271. QETH_CARD_IFNAME(card), cmd->hdr.return_code);
  272. QETH_CARD_TEXT_(card, 2, "L2VL%4x", cmd->hdr.command);
  273. QETH_CARD_TEXT_(card, 2, "err%d", cmd->hdr.return_code);
  274. }
  275. return 0;
  276. }
  277. static int qeth_l2_send_setdelvlan(struct qeth_card *card, __u16 i,
  278. enum qeth_ipa_cmds ipacmd)
  279. {
  280. struct qeth_ipa_cmd *cmd;
  281. struct qeth_cmd_buffer *iob;
  282. QETH_CARD_TEXT_(card, 4, "L2sdv%x", ipacmd);
  283. iob = qeth_get_ipacmd_buffer(card, ipacmd, QETH_PROT_IPV4);
  284. if (!iob)
  285. return -ENOMEM;
  286. cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
  287. cmd->data.setdelvlan.vlan_id = i;
  288. return qeth_send_ipa_cmd(card, iob,
  289. qeth_l2_send_setdelvlan_cb, NULL);
  290. }
  291. static void qeth_l2_process_vlans(struct qeth_card *card)
  292. {
  293. struct qeth_vlan_vid *id;
  294. QETH_CARD_TEXT(card, 3, "L2prcvln");
  295. spin_lock_bh(&card->vlanlock);
  296. list_for_each_entry(id, &card->vid_list, list) {
  297. qeth_l2_send_setdelvlan(card, id->vid, IPA_CMD_SETVLAN);
  298. }
  299. spin_unlock_bh(&card->vlanlock);
  300. }
  301. static int qeth_l2_vlan_rx_add_vid(struct net_device *dev,
  302. __be16 proto, u16 vid)
  303. {
  304. struct qeth_card *card = dev->ml_priv;
  305. struct qeth_vlan_vid *id;
  306. int rc;
  307. QETH_CARD_TEXT_(card, 4, "aid:%d", vid);
  308. if (!vid)
  309. return 0;
  310. if (card->info.type == QETH_CARD_TYPE_OSM) {
  311. QETH_CARD_TEXT(card, 3, "aidOSM");
  312. return 0;
  313. }
  314. if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) {
  315. QETH_CARD_TEXT(card, 3, "aidREC");
  316. return 0;
  317. }
  318. id = kmalloc(sizeof(struct qeth_vlan_vid), GFP_ATOMIC);
  319. if (id) {
  320. id->vid = vid;
  321. rc = qeth_l2_send_setdelvlan(card, vid, IPA_CMD_SETVLAN);
  322. if (rc) {
  323. kfree(id);
  324. return rc;
  325. }
  326. spin_lock_bh(&card->vlanlock);
  327. list_add_tail(&id->list, &card->vid_list);
  328. spin_unlock_bh(&card->vlanlock);
  329. } else {
  330. return -ENOMEM;
  331. }
  332. return 0;
  333. }
  334. static int qeth_l2_vlan_rx_kill_vid(struct net_device *dev,
  335. __be16 proto, u16 vid)
  336. {
  337. struct qeth_vlan_vid *id, *tmpid = NULL;
  338. struct qeth_card *card = dev->ml_priv;
  339. int rc = 0;
  340. QETH_CARD_TEXT_(card, 4, "kid:%d", vid);
  341. if (card->info.type == QETH_CARD_TYPE_OSM) {
  342. QETH_CARD_TEXT(card, 3, "kidOSM");
  343. return 0;
  344. }
  345. if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) {
  346. QETH_CARD_TEXT(card, 3, "kidREC");
  347. return 0;
  348. }
  349. spin_lock_bh(&card->vlanlock);
  350. list_for_each_entry(id, &card->vid_list, list) {
  351. if (id->vid == vid) {
  352. list_del(&id->list);
  353. tmpid = id;
  354. break;
  355. }
  356. }
  357. spin_unlock_bh(&card->vlanlock);
  358. if (tmpid) {
  359. rc = qeth_l2_send_setdelvlan(card, vid, IPA_CMD_DELVLAN);
  360. kfree(tmpid);
  361. }
  362. qeth_l2_set_rx_mode(card->dev);
  363. return rc;
  364. }
  365. static netdev_features_t qeth_l2_fix_features(struct net_device *dev,
  366. netdev_features_t features)
  367. {
  368. struct qeth_card *card = dev->ml_priv;
  369. QETH_DBF_TEXT(SETUP, 2, "fixfeat");
  370. if (!qeth_is_supported(card, IPA_OUTBOUND_CHECKSUM))
  371. features &= ~NETIF_F_IP_CSUM;
  372. if (!qeth_is_supported(card, IPA_INBOUND_CHECKSUM))
  373. features &= ~NETIF_F_RXCSUM;
  374. QETH_DBF_HEX(SETUP, 2, &features, sizeof(features));
  375. return features;
  376. }
  377. static int qeth_l2_set_features(struct net_device *dev,
  378. netdev_features_t features)
  379. {
  380. struct qeth_card *card = dev->ml_priv;
  381. netdev_features_t changed = dev->features ^ features;
  382. QETH_DBF_TEXT(SETUP, 2, "setfeat");
  383. QETH_DBF_HEX(SETUP, 2, &features, sizeof(features));
  384. if (card->state == CARD_STATE_DOWN ||
  385. card->state == CARD_STATE_RECOVER)
  386. return 0;
  387. if (!(changed & NETIF_F_RXCSUM))
  388. return 0;
  389. return qeth_set_rx_csum(card, features & NETIF_F_RXCSUM ? 1 : 0);
  390. }
  391. static void qeth_l2_stop_card(struct qeth_card *card, int recovery_mode)
  392. {
  393. QETH_DBF_TEXT(SETUP , 2, "stopcard");
  394. QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *));
  395. qeth_set_allowed_threads(card, 0, 1);
  396. if (card->read.state == CH_STATE_UP &&
  397. card->write.state == CH_STATE_UP &&
  398. (card->state == CARD_STATE_UP)) {
  399. if (recovery_mode &&
  400. card->info.type != QETH_CARD_TYPE_OSN) {
  401. qeth_l2_stop(card->dev);
  402. } else {
  403. rtnl_lock();
  404. dev_close(card->dev);
  405. rtnl_unlock();
  406. }
  407. card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED;
  408. card->state = CARD_STATE_SOFTSETUP;
  409. }
  410. if (card->state == CARD_STATE_SOFTSETUP) {
  411. qeth_l2_del_all_macs(card, 0);
  412. qeth_clear_ipacmd_list(card);
  413. card->state = CARD_STATE_HARDSETUP;
  414. }
  415. if (card->state == CARD_STATE_HARDSETUP) {
  416. qeth_qdio_clear_card(card, 0);
  417. qeth_clear_qdio_buffers(card);
  418. qeth_clear_working_pool_list(card);
  419. card->state = CARD_STATE_DOWN;
  420. }
  421. if (card->state == CARD_STATE_DOWN) {
  422. qeth_clear_cmd_buffers(&card->read);
  423. qeth_clear_cmd_buffers(&card->write);
  424. }
  425. }
  426. static int qeth_l2_process_inbound_buffer(struct qeth_card *card,
  427. int budget, int *done)
  428. {
  429. int work_done = 0;
  430. struct sk_buff *skb;
  431. struct qeth_hdr *hdr;
  432. unsigned int len;
  433. *done = 0;
  434. WARN_ON_ONCE(!budget);
  435. while (budget) {
  436. skb = qeth_core_get_next_skb(card,
  437. &card->qdio.in_q->bufs[card->rx.b_index],
  438. &card->rx.b_element, &card->rx.e_offset, &hdr);
  439. if (!skb) {
  440. *done = 1;
  441. break;
  442. }
  443. skb->dev = card->dev;
  444. switch (hdr->hdr.l2.id) {
  445. case QETH_HEADER_TYPE_LAYER2:
  446. skb->pkt_type = PACKET_HOST;
  447. skb->protocol = eth_type_trans(skb, skb->dev);
  448. if ((card->dev->features & NETIF_F_RXCSUM)
  449. && ((hdr->hdr.l2.flags[1] &
  450. (QETH_HDR_EXT_CSUM_HDR_REQ |
  451. QETH_HDR_EXT_CSUM_TRANSP_REQ)) ==
  452. (QETH_HDR_EXT_CSUM_HDR_REQ |
  453. QETH_HDR_EXT_CSUM_TRANSP_REQ)))
  454. skb->ip_summed = CHECKSUM_UNNECESSARY;
  455. else
  456. skb->ip_summed = CHECKSUM_NONE;
  457. if (skb->protocol == htons(ETH_P_802_2))
  458. *((__u32 *)skb->cb) = ++card->seqno.pkt_seqno;
  459. len = skb->len;
  460. napi_gro_receive(&card->napi, skb);
  461. break;
  462. case QETH_HEADER_TYPE_OSN:
  463. if (card->info.type == QETH_CARD_TYPE_OSN) {
  464. skb_push(skb, sizeof(struct qeth_hdr));
  465. skb_copy_to_linear_data(skb, hdr,
  466. sizeof(struct qeth_hdr));
  467. len = skb->len;
  468. card->osn_info.data_cb(skb);
  469. break;
  470. }
  471. /* else unknown */
  472. default:
  473. dev_kfree_skb_any(skb);
  474. QETH_CARD_TEXT(card, 3, "inbunkno");
  475. QETH_DBF_HEX(CTRL, 3, hdr, sizeof(*hdr));
  476. continue;
  477. }
  478. work_done++;
  479. budget--;
  480. card->stats.rx_packets++;
  481. card->stats.rx_bytes += len;
  482. }
  483. return work_done;
  484. }
  485. static int qeth_l2_poll(struct napi_struct *napi, int budget)
  486. {
  487. struct qeth_card *card = container_of(napi, struct qeth_card, napi);
  488. int work_done = 0;
  489. struct qeth_qdio_buffer *buffer;
  490. int done;
  491. int new_budget = budget;
  492. if (card->options.performance_stats) {
  493. card->perf_stats.inbound_cnt++;
  494. card->perf_stats.inbound_start_time = qeth_get_micros();
  495. }
  496. while (1) {
  497. if (!card->rx.b_count) {
  498. card->rx.qdio_err = 0;
  499. card->rx.b_count = qdio_get_next_buffers(
  500. card->data.ccwdev, 0, &card->rx.b_index,
  501. &card->rx.qdio_err);
  502. if (card->rx.b_count <= 0) {
  503. card->rx.b_count = 0;
  504. break;
  505. }
  506. card->rx.b_element =
  507. &card->qdio.in_q->bufs[card->rx.b_index]
  508. .buffer->element[0];
  509. card->rx.e_offset = 0;
  510. }
  511. while (card->rx.b_count) {
  512. buffer = &card->qdio.in_q->bufs[card->rx.b_index];
  513. if (!(card->rx.qdio_err &&
  514. qeth_check_qdio_errors(card, buffer->buffer,
  515. card->rx.qdio_err, "qinerr")))
  516. work_done += qeth_l2_process_inbound_buffer(
  517. card, new_budget, &done);
  518. else
  519. done = 1;
  520. if (done) {
  521. if (card->options.performance_stats)
  522. card->perf_stats.bufs_rec++;
  523. qeth_put_buffer_pool_entry(card,
  524. buffer->pool_entry);
  525. qeth_queue_input_buffer(card, card->rx.b_index);
  526. card->rx.b_count--;
  527. if (card->rx.b_count) {
  528. card->rx.b_index =
  529. (card->rx.b_index + 1) %
  530. QDIO_MAX_BUFFERS_PER_Q;
  531. card->rx.b_element =
  532. &card->qdio.in_q
  533. ->bufs[card->rx.b_index]
  534. .buffer->element[0];
  535. card->rx.e_offset = 0;
  536. }
  537. }
  538. if (work_done >= budget)
  539. goto out;
  540. else
  541. new_budget = budget - work_done;
  542. }
  543. }
  544. napi_complete(napi);
  545. if (qdio_start_irq(card->data.ccwdev, 0))
  546. napi_schedule(&card->napi);
  547. out:
  548. if (card->options.performance_stats)
  549. card->perf_stats.inbound_time += qeth_get_micros() -
  550. card->perf_stats.inbound_start_time;
  551. return work_done;
  552. }
  553. static int qeth_l2_send_setdelmac(struct qeth_card *card, __u8 *mac,
  554. enum qeth_ipa_cmds ipacmd)
  555. {
  556. struct qeth_ipa_cmd *cmd;
  557. struct qeth_cmd_buffer *iob;
  558. QETH_CARD_TEXT(card, 2, "L2sdmac");
  559. iob = qeth_get_ipacmd_buffer(card, ipacmd, QETH_PROT_IPV4);
  560. if (!iob)
  561. return -ENOMEM;
  562. cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
  563. cmd->data.setdelmac.mac_length = OSA_ADDR_LEN;
  564. memcpy(&cmd->data.setdelmac.mac, mac, OSA_ADDR_LEN);
  565. return qeth_send_ipa_cmd(card, iob, NULL, NULL);
  566. }
  567. static int qeth_l2_send_setmac(struct qeth_card *card, __u8 *mac)
  568. {
  569. int rc;
  570. QETH_CARD_TEXT(card, 2, "L2Setmac");
  571. rc = qeth_setdel_makerc(card, qeth_l2_send_setdelmac(card, mac,
  572. IPA_CMD_SETVMAC));
  573. if (rc == 0) {
  574. card->info.mac_bits |= QETH_LAYER2_MAC_REGISTERED;
  575. memcpy(card->dev->dev_addr, mac, OSA_ADDR_LEN);
  576. dev_info(&card->gdev->dev,
  577. "MAC address %pM successfully registered on device %s\n",
  578. card->dev->dev_addr, card->dev->name);
  579. } else {
  580. card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED;
  581. switch (rc) {
  582. case -EEXIST:
  583. dev_warn(&card->gdev->dev,
  584. "MAC address %pM already exists\n", mac);
  585. break;
  586. case -EPERM:
  587. dev_warn(&card->gdev->dev,
  588. "MAC address %pM is not authorized\n", mac);
  589. break;
  590. }
  591. }
  592. return rc;
  593. }
  594. static int qeth_l2_send_delmac(struct qeth_card *card, __u8 *mac)
  595. {
  596. int rc;
  597. QETH_CARD_TEXT(card, 2, "L2Delmac");
  598. if (!(card->info.mac_bits & QETH_LAYER2_MAC_REGISTERED))
  599. return 0;
  600. rc = qeth_setdel_makerc(card, qeth_l2_send_setdelmac(card, mac,
  601. IPA_CMD_DELVMAC));
  602. if (rc == 0)
  603. card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED;
  604. return rc;
  605. }
  606. static int qeth_l2_request_initial_mac(struct qeth_card *card)
  607. {
  608. int rc = 0;
  609. char vendor_pre[] = {0x02, 0x00, 0x00};
  610. QETH_DBF_TEXT(SETUP, 2, "doL2init");
  611. QETH_DBF_TEXT_(SETUP, 2, "doL2%s", CARD_BUS_ID(card));
  612. if (qeth_is_supported(card, IPA_SETADAPTERPARMS)) {
  613. rc = qeth_query_setadapterparms(card);
  614. if (rc) {
  615. QETH_DBF_MESSAGE(2, "could not query adapter "
  616. "parameters on device %s: x%x\n",
  617. CARD_BUS_ID(card), rc);
  618. }
  619. }
  620. if (card->info.type == QETH_CARD_TYPE_IQD ||
  621. card->info.type == QETH_CARD_TYPE_OSM ||
  622. card->info.type == QETH_CARD_TYPE_OSX ||
  623. card->info.guestlan) {
  624. rc = qeth_setadpparms_change_macaddr(card);
  625. if (rc) {
  626. QETH_DBF_MESSAGE(2, "couldn't get MAC address on "
  627. "device %s: x%x\n", CARD_BUS_ID(card), rc);
  628. QETH_DBF_TEXT_(SETUP, 2, "1err%04x", rc);
  629. return rc;
  630. }
  631. QETH_DBF_HEX(SETUP, 2, card->dev->dev_addr, OSA_ADDR_LEN);
  632. } else {
  633. eth_random_addr(card->dev->dev_addr);
  634. memcpy(card->dev->dev_addr, vendor_pre, 3);
  635. }
  636. return 0;
  637. }
  638. static int qeth_l2_set_mac_address(struct net_device *dev, void *p)
  639. {
  640. struct sockaddr *addr = p;
  641. struct qeth_card *card = dev->ml_priv;
  642. int rc = 0;
  643. QETH_CARD_TEXT(card, 3, "setmac");
  644. if (qeth_l2_verify_dev(dev) != QETH_REAL_CARD) {
  645. QETH_CARD_TEXT(card, 3, "setmcINV");
  646. return -EOPNOTSUPP;
  647. }
  648. if (card->info.type == QETH_CARD_TYPE_OSN ||
  649. card->info.type == QETH_CARD_TYPE_OSM ||
  650. card->info.type == QETH_CARD_TYPE_OSX) {
  651. QETH_CARD_TEXT(card, 3, "setmcTYP");
  652. return -EOPNOTSUPP;
  653. }
  654. QETH_CARD_HEX(card, 3, addr->sa_data, OSA_ADDR_LEN);
  655. if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) {
  656. QETH_CARD_TEXT(card, 3, "setmcREC");
  657. return -ERESTARTSYS;
  658. }
  659. rc = qeth_l2_send_delmac(card, &card->dev->dev_addr[0]);
  660. if (!rc || (rc == -ENOENT))
  661. rc = qeth_l2_send_setmac(card, addr->sa_data);
  662. return rc ? -EINVAL : 0;
  663. }
  664. static void qeth_promisc_to_bridge(struct qeth_card *card)
  665. {
  666. struct net_device *dev = card->dev;
  667. enum qeth_ipa_promisc_modes promisc_mode;
  668. int role;
  669. int rc;
  670. QETH_CARD_TEXT(card, 3, "pmisc2br");
  671. if (!card->options.sbp.reflect_promisc)
  672. return;
  673. promisc_mode = (dev->flags & IFF_PROMISC) ? SET_PROMISC_MODE_ON
  674. : SET_PROMISC_MODE_OFF;
  675. if (promisc_mode == card->info.promisc_mode)
  676. return;
  677. if (promisc_mode == SET_PROMISC_MODE_ON) {
  678. if (card->options.sbp.reflect_promisc_primary)
  679. role = QETH_SBP_ROLE_PRIMARY;
  680. else
  681. role = QETH_SBP_ROLE_SECONDARY;
  682. } else
  683. role = QETH_SBP_ROLE_NONE;
  684. rc = qeth_bridgeport_setrole(card, role);
  685. QETH_DBF_TEXT_(SETUP, 2, "bpm%c%04x",
  686. (promisc_mode == SET_PROMISC_MODE_ON) ? '+' : '-', rc);
  687. if (!rc) {
  688. card->options.sbp.role = role;
  689. card->info.promisc_mode = promisc_mode;
  690. }
  691. }
  692. /* New MAC address is added to the hash table and marked to be written on card
  693. * only if there is not in the hash table storage already
  694. *
  695. */
  696. static void
  697. qeth_l2_add_mac(struct qeth_card *card, struct netdev_hw_addr *ha, u8 is_uc)
  698. {
  699. struct qeth_mac *mac;
  700. hash_for_each_possible(card->mac_htable, mac, hnode,
  701. qeth_l2_mac_hash(ha->addr)) {
  702. if (is_uc == mac->is_uc &&
  703. !memcmp(ha->addr, mac->mac_addr, OSA_ADDR_LEN)) {
  704. mac->disp_flag = QETH_DISP_MAC_DO_NOTHING;
  705. return;
  706. }
  707. }
  708. mac = kzalloc(sizeof(struct qeth_mac), GFP_ATOMIC);
  709. if (!mac)
  710. return;
  711. memcpy(mac->mac_addr, ha->addr, OSA_ADDR_LEN);
  712. mac->is_uc = is_uc;
  713. mac->disp_flag = QETH_DISP_MAC_ADD;
  714. hash_add(card->mac_htable, &mac->hnode,
  715. qeth_l2_mac_hash(mac->mac_addr));
  716. }
  717. static void qeth_l2_set_rx_mode(struct net_device *dev)
  718. {
  719. struct qeth_card *card = dev->ml_priv;
  720. struct netdev_hw_addr *ha;
  721. struct qeth_mac *mac;
  722. struct hlist_node *tmp;
  723. int i;
  724. int rc;
  725. if (card->info.type == QETH_CARD_TYPE_OSN)
  726. return;
  727. QETH_CARD_TEXT(card, 3, "setmulti");
  728. if (qeth_threads_running(card, QETH_RECOVER_THREAD) &&
  729. (card->state != CARD_STATE_UP))
  730. return;
  731. spin_lock_bh(&card->mclock);
  732. netdev_for_each_mc_addr(ha, dev)
  733. qeth_l2_add_mac(card, ha, 0);
  734. netdev_for_each_uc_addr(ha, dev)
  735. qeth_l2_add_mac(card, ha, 1);
  736. hash_for_each_safe(card->mac_htable, i, tmp, mac, hnode) {
  737. if (mac->disp_flag == QETH_DISP_MAC_DELETE) {
  738. if (!mac->is_uc)
  739. rc = qeth_l2_send_delgroupmac(card,
  740. mac->mac_addr);
  741. else {
  742. rc = qeth_l2_send_setdelmac(card, mac->mac_addr,
  743. IPA_CMD_DELVMAC);
  744. }
  745. hash_del(&mac->hnode);
  746. kfree(mac);
  747. } else if (mac->disp_flag == QETH_DISP_MAC_ADD) {
  748. rc = qeth_l2_write_mac(card, mac);
  749. if (rc) {
  750. hash_del(&mac->hnode);
  751. kfree(mac);
  752. } else
  753. mac->disp_flag = QETH_DISP_MAC_DELETE;
  754. } else
  755. mac->disp_flag = QETH_DISP_MAC_DELETE;
  756. }
  757. spin_unlock_bh(&card->mclock);
  758. if (qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE))
  759. qeth_setadp_promisc_mode(card);
  760. else
  761. qeth_promisc_to_bridge(card);
  762. }
  763. static int qeth_l2_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
  764. {
  765. int rc;
  766. struct qeth_hdr *hdr = NULL;
  767. int elements = 0;
  768. struct qeth_card *card = dev->ml_priv;
  769. struct sk_buff *new_skb = skb;
  770. int cast_type = qeth_l2_get_cast_type(card, skb);
  771. struct qeth_qdio_out_q *queue;
  772. int tx_bytes = skb->len;
  773. int data_offset = -1;
  774. int elements_needed = 0;
  775. int hd_len = 0;
  776. if (card->qdio.do_prio_queueing || (cast_type &&
  777. card->info.is_multicast_different))
  778. queue = card->qdio.out_qs[qeth_get_priority_queue(card, skb,
  779. qeth_get_ip_version(skb), cast_type)];
  780. else
  781. queue = card->qdio.out_qs[card->qdio.default_out_queue];
  782. if ((card->state != CARD_STATE_UP) || !card->lan_online) {
  783. card->stats.tx_carrier_errors++;
  784. goto tx_drop;
  785. }
  786. if ((card->info.type == QETH_CARD_TYPE_OSN) &&
  787. (skb->protocol == htons(ETH_P_IPV6)))
  788. goto tx_drop;
  789. if (card->options.performance_stats) {
  790. card->perf_stats.outbound_cnt++;
  791. card->perf_stats.outbound_start_time = qeth_get_micros();
  792. }
  793. netif_stop_queue(dev);
  794. if (card->info.type == QETH_CARD_TYPE_OSN)
  795. hdr = (struct qeth_hdr *)skb->data;
  796. else {
  797. if (card->info.type == QETH_CARD_TYPE_IQD) {
  798. new_skb = skb;
  799. data_offset = ETH_HLEN;
  800. hd_len = ETH_HLEN;
  801. hdr = kmem_cache_alloc(qeth_core_header_cache,
  802. GFP_ATOMIC);
  803. if (!hdr)
  804. goto tx_drop;
  805. elements_needed++;
  806. skb_reset_mac_header(new_skb);
  807. qeth_l2_fill_header(card, hdr, new_skb, cast_type);
  808. hdr->hdr.l2.pkt_length = new_skb->len;
  809. memcpy(((char *)hdr) + sizeof(struct qeth_hdr),
  810. skb_mac_header(new_skb), ETH_HLEN);
  811. } else {
  812. /* create a clone with writeable headroom */
  813. new_skb = skb_realloc_headroom(skb,
  814. sizeof(struct qeth_hdr));
  815. if (!new_skb)
  816. goto tx_drop;
  817. hdr = (struct qeth_hdr *)skb_push(new_skb,
  818. sizeof(struct qeth_hdr));
  819. skb_set_mac_header(new_skb, sizeof(struct qeth_hdr));
  820. qeth_l2_fill_header(card, hdr, new_skb, cast_type);
  821. if (new_skb->ip_summed == CHECKSUM_PARTIAL)
  822. qeth_l2_hdr_csum(card, hdr, new_skb);
  823. }
  824. }
  825. elements = qeth_get_elements_no(card, new_skb, elements_needed);
  826. if (!elements) {
  827. if (data_offset >= 0)
  828. kmem_cache_free(qeth_core_header_cache, hdr);
  829. goto tx_drop;
  830. }
  831. if (card->info.type != QETH_CARD_TYPE_IQD) {
  832. if (qeth_hdr_chk_and_bounce(new_skb, &hdr,
  833. sizeof(struct qeth_hdr_layer2)))
  834. goto tx_drop;
  835. rc = qeth_do_send_packet(card, queue, new_skb, hdr,
  836. elements);
  837. } else
  838. rc = qeth_do_send_packet_fast(card, queue, new_skb, hdr,
  839. elements, data_offset, hd_len);
  840. if (!rc) {
  841. card->stats.tx_packets++;
  842. card->stats.tx_bytes += tx_bytes;
  843. if (new_skb != skb)
  844. dev_kfree_skb_any(skb);
  845. rc = NETDEV_TX_OK;
  846. } else {
  847. if (data_offset >= 0)
  848. kmem_cache_free(qeth_core_header_cache, hdr);
  849. if (rc == -EBUSY) {
  850. if (new_skb != skb)
  851. dev_kfree_skb_any(new_skb);
  852. return NETDEV_TX_BUSY;
  853. } else
  854. goto tx_drop;
  855. }
  856. netif_wake_queue(dev);
  857. if (card->options.performance_stats)
  858. card->perf_stats.outbound_time += qeth_get_micros() -
  859. card->perf_stats.outbound_start_time;
  860. return rc;
  861. tx_drop:
  862. card->stats.tx_dropped++;
  863. card->stats.tx_errors++;
  864. if ((new_skb != skb) && new_skb)
  865. dev_kfree_skb_any(new_skb);
  866. dev_kfree_skb_any(skb);
  867. netif_wake_queue(dev);
  868. return NETDEV_TX_OK;
  869. }
  870. static int __qeth_l2_open(struct net_device *dev)
  871. {
  872. struct qeth_card *card = dev->ml_priv;
  873. int rc = 0;
  874. QETH_CARD_TEXT(card, 4, "qethopen");
  875. if (card->state == CARD_STATE_UP)
  876. return rc;
  877. if (card->state != CARD_STATE_SOFTSETUP)
  878. return -ENODEV;
  879. if ((card->info.type != QETH_CARD_TYPE_OSN) &&
  880. (!(card->info.mac_bits & QETH_LAYER2_MAC_REGISTERED))) {
  881. QETH_CARD_TEXT(card, 4, "nomacadr");
  882. return -EPERM;
  883. }
  884. card->data.state = CH_STATE_UP;
  885. card->state = CARD_STATE_UP;
  886. netif_start_queue(dev);
  887. if (qdio_stop_irq(card->data.ccwdev, 0) >= 0) {
  888. napi_enable(&card->napi);
  889. napi_schedule(&card->napi);
  890. } else
  891. rc = -EIO;
  892. return rc;
  893. }
  894. static int qeth_l2_open(struct net_device *dev)
  895. {
  896. struct qeth_card *card = dev->ml_priv;
  897. QETH_CARD_TEXT(card, 5, "qethope_");
  898. if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) {
  899. QETH_CARD_TEXT(card, 3, "openREC");
  900. return -ERESTARTSYS;
  901. }
  902. return __qeth_l2_open(dev);
  903. }
  904. static int qeth_l2_stop(struct net_device *dev)
  905. {
  906. struct qeth_card *card = dev->ml_priv;
  907. QETH_CARD_TEXT(card, 4, "qethstop");
  908. netif_tx_disable(dev);
  909. if (card->state == CARD_STATE_UP) {
  910. card->state = CARD_STATE_SOFTSETUP;
  911. napi_disable(&card->napi);
  912. }
  913. return 0;
  914. }
  915. static const struct device_type qeth_l2_devtype = {
  916. .name = "qeth_layer2",
  917. .groups = qeth_l2_attr_groups,
  918. };
  919. static int qeth_l2_probe_device(struct ccwgroup_device *gdev)
  920. {
  921. struct qeth_card *card = dev_get_drvdata(&gdev->dev);
  922. int rc;
  923. if (gdev->dev.type == &qeth_generic_devtype) {
  924. rc = qeth_l2_create_device_attributes(&gdev->dev);
  925. if (rc)
  926. return rc;
  927. }
  928. INIT_LIST_HEAD(&card->vid_list);
  929. hash_init(card->mac_htable);
  930. card->options.layer2 = 1;
  931. card->info.hwtrap = 0;
  932. return 0;
  933. }
  934. static void qeth_l2_remove_device(struct ccwgroup_device *cgdev)
  935. {
  936. struct qeth_card *card = dev_get_drvdata(&cgdev->dev);
  937. if (cgdev->dev.type == &qeth_generic_devtype)
  938. qeth_l2_remove_device_attributes(&cgdev->dev);
  939. qeth_set_allowed_threads(card, 0, 1);
  940. wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0);
  941. if (cgdev->state == CCWGROUP_ONLINE)
  942. qeth_l2_set_offline(cgdev);
  943. if (card->dev) {
  944. unregister_netdev(card->dev);
  945. free_netdev(card->dev);
  946. card->dev = NULL;
  947. }
  948. return;
  949. }
  950. static const struct ethtool_ops qeth_l2_ethtool_ops = {
  951. .get_link = ethtool_op_get_link,
  952. .get_strings = qeth_core_get_strings,
  953. .get_ethtool_stats = qeth_core_get_ethtool_stats,
  954. .get_sset_count = qeth_core_get_sset_count,
  955. .get_drvinfo = qeth_core_get_drvinfo,
  956. .get_settings = qeth_core_ethtool_get_settings,
  957. };
  958. static const struct ethtool_ops qeth_l2_osn_ops = {
  959. .get_strings = qeth_core_get_strings,
  960. .get_ethtool_stats = qeth_core_get_ethtool_stats,
  961. .get_sset_count = qeth_core_get_sset_count,
  962. .get_drvinfo = qeth_core_get_drvinfo,
  963. };
  964. static const struct net_device_ops qeth_l2_netdev_ops = {
  965. .ndo_open = qeth_l2_open,
  966. .ndo_stop = qeth_l2_stop,
  967. .ndo_get_stats = qeth_get_stats,
  968. .ndo_start_xmit = qeth_l2_hard_start_xmit,
  969. .ndo_validate_addr = eth_validate_addr,
  970. .ndo_set_rx_mode = qeth_l2_set_rx_mode,
  971. .ndo_do_ioctl = qeth_l2_do_ioctl,
  972. .ndo_set_mac_address = qeth_l2_set_mac_address,
  973. .ndo_change_mtu = qeth_change_mtu,
  974. .ndo_vlan_rx_add_vid = qeth_l2_vlan_rx_add_vid,
  975. .ndo_vlan_rx_kill_vid = qeth_l2_vlan_rx_kill_vid,
  976. .ndo_tx_timeout = qeth_tx_timeout,
  977. .ndo_fix_features = qeth_l2_fix_features,
  978. .ndo_set_features = qeth_l2_set_features
  979. };
  980. static int qeth_l2_setup_netdev(struct qeth_card *card)
  981. {
  982. switch (card->info.type) {
  983. case QETH_CARD_TYPE_IQD:
  984. card->dev = alloc_netdev(0, "hsi%d", NET_NAME_UNKNOWN,
  985. ether_setup);
  986. break;
  987. case QETH_CARD_TYPE_OSN:
  988. card->dev = alloc_netdev(0, "osn%d", NET_NAME_UNKNOWN,
  989. ether_setup);
  990. break;
  991. default:
  992. card->dev = alloc_etherdev(0);
  993. }
  994. if (!card->dev)
  995. return -ENODEV;
  996. card->dev->ml_priv = card;
  997. card->dev->watchdog_timeo = QETH_TX_TIMEOUT;
  998. card->dev->mtu = card->info.initial_mtu;
  999. card->dev->netdev_ops = &qeth_l2_netdev_ops;
  1000. if (card->info.type == QETH_CARD_TYPE_OSN) {
  1001. card->dev->ethtool_ops = &qeth_l2_osn_ops;
  1002. card->dev->flags |= IFF_NOARP;
  1003. } else {
  1004. card->dev->ethtool_ops = &qeth_l2_ethtool_ops;
  1005. }
  1006. card->dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
  1007. if (card->info.type == QETH_CARD_TYPE_OSD && !card->info.guestlan) {
  1008. card->dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_RXCSUM;
  1009. /* Turn on RX offloading per default */
  1010. card->dev->features |= NETIF_F_RXCSUM;
  1011. }
  1012. card->info.broadcast_capable = 1;
  1013. qeth_l2_request_initial_mac(card);
  1014. SET_NETDEV_DEV(card->dev, &card->gdev->dev);
  1015. netif_napi_add(card->dev, &card->napi, qeth_l2_poll, QETH_NAPI_WEIGHT);
  1016. netif_carrier_off(card->dev);
  1017. return register_netdev(card->dev);
  1018. }
  1019. static int qeth_l2_start_ipassists(struct qeth_card *card)
  1020. {
  1021. /* configure isolation level */
  1022. if (qeth_set_access_ctrl_online(card, 0))
  1023. return -ENODEV;
  1024. if (qeth_is_supported(card, IPA_INBOUND_CHECKSUM))
  1025. qeth_set_rx_csum(card, 1);
  1026. qeth_start_ipa_tx_checksum(card);
  1027. return 0;
  1028. }
  1029. static int __qeth_l2_set_online(struct ccwgroup_device *gdev, int recovery_mode)
  1030. {
  1031. struct qeth_card *card = dev_get_drvdata(&gdev->dev);
  1032. int rc = 0;
  1033. enum qeth_card_states recover_flag;
  1034. mutex_lock(&card->discipline_mutex);
  1035. mutex_lock(&card->conf_mutex);
  1036. QETH_DBF_TEXT(SETUP, 2, "setonlin");
  1037. QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *));
  1038. recover_flag = card->state;
  1039. rc = qeth_core_hardsetup_card(card);
  1040. if (rc) {
  1041. QETH_DBF_TEXT_(SETUP, 2, "2err%04x", rc);
  1042. rc = -ENODEV;
  1043. goto out_remove;
  1044. }
  1045. qeth_bridgeport_query_support(card);
  1046. if (card->options.sbp.supported_funcs)
  1047. dev_info(&card->gdev->dev,
  1048. "The device represents a Bridge Capable Port\n");
  1049. qeth_trace_features(card);
  1050. if (!card->dev && qeth_l2_setup_netdev(card)) {
  1051. rc = -ENODEV;
  1052. goto out_remove;
  1053. }
  1054. if (card->info.type != QETH_CARD_TYPE_OSN)
  1055. qeth_l2_send_setmac(card, &card->dev->dev_addr[0]);
  1056. if (qeth_is_diagass_supported(card, QETH_DIAGS_CMD_TRAP)) {
  1057. if (card->info.hwtrap &&
  1058. qeth_hw_trap(card, QETH_DIAGS_TRAP_ARM))
  1059. card->info.hwtrap = 0;
  1060. } else
  1061. card->info.hwtrap = 0;
  1062. qeth_l2_setup_bridgeport_attrs(card);
  1063. card->state = CARD_STATE_HARDSETUP;
  1064. memset(&card->rx, 0, sizeof(struct qeth_rx));
  1065. qeth_print_status_message(card);
  1066. /* softsetup */
  1067. QETH_DBF_TEXT(SETUP, 2, "softsetp");
  1068. if ((card->info.type == QETH_CARD_TYPE_OSD) ||
  1069. (card->info.type == QETH_CARD_TYPE_OSX)) {
  1070. if (qeth_l2_start_ipassists(card))
  1071. goto out_remove;
  1072. }
  1073. if (card->info.type != QETH_CARD_TYPE_OSN &&
  1074. card->info.type != QETH_CARD_TYPE_OSM)
  1075. qeth_l2_process_vlans(card);
  1076. netif_tx_disable(card->dev);
  1077. rc = qeth_init_qdio_queues(card);
  1078. if (rc) {
  1079. QETH_DBF_TEXT_(SETUP, 2, "6err%d", rc);
  1080. rc = -ENODEV;
  1081. goto out_remove;
  1082. }
  1083. card->state = CARD_STATE_SOFTSETUP;
  1084. if (card->lan_online)
  1085. netif_carrier_on(card->dev);
  1086. else
  1087. netif_carrier_off(card->dev);
  1088. qeth_set_allowed_threads(card, 0xffffffff, 0);
  1089. if (recover_flag == CARD_STATE_RECOVER) {
  1090. if (recovery_mode &&
  1091. card->info.type != QETH_CARD_TYPE_OSN) {
  1092. __qeth_l2_open(card->dev);
  1093. } else {
  1094. rtnl_lock();
  1095. dev_open(card->dev);
  1096. rtnl_unlock();
  1097. }
  1098. /* this also sets saved unicast addresses */
  1099. qeth_l2_set_rx_mode(card->dev);
  1100. }
  1101. /* let user_space know that device is online */
  1102. kobject_uevent(&gdev->dev.kobj, KOBJ_CHANGE);
  1103. mutex_unlock(&card->conf_mutex);
  1104. mutex_unlock(&card->discipline_mutex);
  1105. return 0;
  1106. out_remove:
  1107. qeth_l2_stop_card(card, 0);
  1108. ccw_device_set_offline(CARD_DDEV(card));
  1109. ccw_device_set_offline(CARD_WDEV(card));
  1110. ccw_device_set_offline(CARD_RDEV(card));
  1111. qdio_free(CARD_DDEV(card));
  1112. if (recover_flag == CARD_STATE_RECOVER)
  1113. card->state = CARD_STATE_RECOVER;
  1114. else
  1115. card->state = CARD_STATE_DOWN;
  1116. mutex_unlock(&card->conf_mutex);
  1117. mutex_unlock(&card->discipline_mutex);
  1118. return rc;
  1119. }
  1120. static int qeth_l2_set_online(struct ccwgroup_device *gdev)
  1121. {
  1122. return __qeth_l2_set_online(gdev, 0);
  1123. }
  1124. static int __qeth_l2_set_offline(struct ccwgroup_device *cgdev,
  1125. int recovery_mode)
  1126. {
  1127. struct qeth_card *card = dev_get_drvdata(&cgdev->dev);
  1128. int rc = 0, rc2 = 0, rc3 = 0;
  1129. enum qeth_card_states recover_flag;
  1130. mutex_lock(&card->discipline_mutex);
  1131. mutex_lock(&card->conf_mutex);
  1132. QETH_DBF_TEXT(SETUP, 3, "setoffl");
  1133. QETH_DBF_HEX(SETUP, 3, &card, sizeof(void *));
  1134. if (card->dev && netif_carrier_ok(card->dev))
  1135. netif_carrier_off(card->dev);
  1136. recover_flag = card->state;
  1137. if ((!recovery_mode && card->info.hwtrap) || card->info.hwtrap == 2) {
  1138. qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM);
  1139. card->info.hwtrap = 1;
  1140. }
  1141. qeth_l2_stop_card(card, recovery_mode);
  1142. rc = ccw_device_set_offline(CARD_DDEV(card));
  1143. rc2 = ccw_device_set_offline(CARD_WDEV(card));
  1144. rc3 = ccw_device_set_offline(CARD_RDEV(card));
  1145. if (!rc)
  1146. rc = (rc2) ? rc2 : rc3;
  1147. if (rc)
  1148. QETH_DBF_TEXT_(SETUP, 2, "1err%d", rc);
  1149. qdio_free(CARD_DDEV(card));
  1150. if (recover_flag == CARD_STATE_UP)
  1151. card->state = CARD_STATE_RECOVER;
  1152. /* let user_space know that device is offline */
  1153. kobject_uevent(&cgdev->dev.kobj, KOBJ_CHANGE);
  1154. mutex_unlock(&card->conf_mutex);
  1155. mutex_unlock(&card->discipline_mutex);
  1156. return 0;
  1157. }
  1158. static int qeth_l2_set_offline(struct ccwgroup_device *cgdev)
  1159. {
  1160. return __qeth_l2_set_offline(cgdev, 0);
  1161. }
  1162. static int qeth_l2_recover(void *ptr)
  1163. {
  1164. struct qeth_card *card;
  1165. int rc = 0;
  1166. card = (struct qeth_card *) ptr;
  1167. QETH_CARD_TEXT(card, 2, "recover1");
  1168. if (!qeth_do_run_thread(card, QETH_RECOVER_THREAD))
  1169. return 0;
  1170. QETH_CARD_TEXT(card, 2, "recover2");
  1171. dev_warn(&card->gdev->dev,
  1172. "A recovery process has been started for the device\n");
  1173. qeth_set_recovery_task(card);
  1174. __qeth_l2_set_offline(card->gdev, 1);
  1175. rc = __qeth_l2_set_online(card->gdev, 1);
  1176. if (!rc)
  1177. dev_info(&card->gdev->dev,
  1178. "Device successfully recovered!\n");
  1179. else {
  1180. qeth_close_dev(card);
  1181. dev_warn(&card->gdev->dev, "The qeth device driver "
  1182. "failed to recover an error on the device\n");
  1183. }
  1184. qeth_clear_recovery_task(card);
  1185. qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD);
  1186. qeth_clear_thread_running_bit(card, QETH_RECOVER_THREAD);
  1187. return 0;
  1188. }
  1189. static int __init qeth_l2_init(void)
  1190. {
  1191. pr_info("register layer 2 discipline\n");
  1192. return 0;
  1193. }
  1194. static void __exit qeth_l2_exit(void)
  1195. {
  1196. pr_info("unregister layer 2 discipline\n");
  1197. }
  1198. static void qeth_l2_shutdown(struct ccwgroup_device *gdev)
  1199. {
  1200. struct qeth_card *card = dev_get_drvdata(&gdev->dev);
  1201. qeth_set_allowed_threads(card, 0, 1);
  1202. if ((gdev->state == CCWGROUP_ONLINE) && card->info.hwtrap)
  1203. qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM);
  1204. qeth_qdio_clear_card(card, 0);
  1205. qeth_clear_qdio_buffers(card);
  1206. qdio_free(CARD_DDEV(card));
  1207. }
  1208. static int qeth_l2_pm_suspend(struct ccwgroup_device *gdev)
  1209. {
  1210. struct qeth_card *card = dev_get_drvdata(&gdev->dev);
  1211. if (card->dev)
  1212. netif_device_detach(card->dev);
  1213. qeth_set_allowed_threads(card, 0, 1);
  1214. wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0);
  1215. if (gdev->state == CCWGROUP_OFFLINE)
  1216. return 0;
  1217. if (card->state == CARD_STATE_UP) {
  1218. if (card->info.hwtrap)
  1219. qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM);
  1220. __qeth_l2_set_offline(card->gdev, 1);
  1221. } else
  1222. __qeth_l2_set_offline(card->gdev, 0);
  1223. return 0;
  1224. }
  1225. static int qeth_l2_pm_resume(struct ccwgroup_device *gdev)
  1226. {
  1227. struct qeth_card *card = dev_get_drvdata(&gdev->dev);
  1228. int rc = 0;
  1229. if (gdev->state == CCWGROUP_OFFLINE)
  1230. goto out;
  1231. if (card->state == CARD_STATE_RECOVER) {
  1232. rc = __qeth_l2_set_online(card->gdev, 1);
  1233. if (rc) {
  1234. rtnl_lock();
  1235. dev_close(card->dev);
  1236. rtnl_unlock();
  1237. }
  1238. } else
  1239. rc = __qeth_l2_set_online(card->gdev, 0);
  1240. out:
  1241. qeth_set_allowed_threads(card, 0xffffffff, 0);
  1242. if (card->dev)
  1243. netif_device_attach(card->dev);
  1244. if (rc)
  1245. dev_warn(&card->gdev->dev, "The qeth device driver "
  1246. "failed to recover an error on the device\n");
  1247. return rc;
  1248. }
  1249. /* Returns zero if the command is successfully "consumed" */
  1250. static int qeth_l2_control_event(struct qeth_card *card,
  1251. struct qeth_ipa_cmd *cmd)
  1252. {
  1253. switch (cmd->hdr.command) {
  1254. case IPA_CMD_SETBRIDGEPORT_OSA:
  1255. case IPA_CMD_SETBRIDGEPORT_IQD:
  1256. if (cmd->data.sbp.hdr.command_code ==
  1257. IPA_SBP_BRIDGE_PORT_STATE_CHANGE) {
  1258. qeth_bridge_state_change(card, cmd);
  1259. return 0;
  1260. } else
  1261. return 1;
  1262. case IPA_CMD_ADDRESS_CHANGE_NOTIF:
  1263. qeth_bridge_host_event(card, cmd);
  1264. return 0;
  1265. default:
  1266. return 1;
  1267. }
  1268. }
  1269. struct qeth_discipline qeth_l2_discipline = {
  1270. .devtype = &qeth_l2_devtype,
  1271. .start_poll = qeth_qdio_start_poll,
  1272. .input_handler = (qdio_handler_t *) qeth_qdio_input_handler,
  1273. .output_handler = (qdio_handler_t *) qeth_qdio_output_handler,
  1274. .recover = qeth_l2_recover,
  1275. .setup = qeth_l2_probe_device,
  1276. .remove = qeth_l2_remove_device,
  1277. .set_online = qeth_l2_set_online,
  1278. .set_offline = qeth_l2_set_offline,
  1279. .shutdown = qeth_l2_shutdown,
  1280. .freeze = qeth_l2_pm_suspend,
  1281. .thaw = qeth_l2_pm_resume,
  1282. .restore = qeth_l2_pm_resume,
  1283. .control_event_handler = qeth_l2_control_event,
  1284. };
  1285. EXPORT_SYMBOL_GPL(qeth_l2_discipline);
  1286. static int qeth_osn_send_control_data(struct qeth_card *card, int len,
  1287. struct qeth_cmd_buffer *iob)
  1288. {
  1289. unsigned long flags;
  1290. int rc = 0;
  1291. QETH_CARD_TEXT(card, 5, "osndctrd");
  1292. wait_event(card->wait_q,
  1293. atomic_cmpxchg(&card->write.irq_pending, 0, 1) == 0);
  1294. qeth_prepare_control_data(card, len, iob);
  1295. QETH_CARD_TEXT(card, 6, "osnoirqp");
  1296. spin_lock_irqsave(get_ccwdev_lock(card->write.ccwdev), flags);
  1297. rc = ccw_device_start(card->write.ccwdev, &card->write.ccw,
  1298. (addr_t) iob, 0, 0);
  1299. spin_unlock_irqrestore(get_ccwdev_lock(card->write.ccwdev), flags);
  1300. if (rc) {
  1301. QETH_DBF_MESSAGE(2, "qeth_osn_send_control_data: "
  1302. "ccw_device_start rc = %i\n", rc);
  1303. QETH_CARD_TEXT_(card, 2, " err%d", rc);
  1304. qeth_release_buffer(iob->channel, iob);
  1305. atomic_set(&card->write.irq_pending, 0);
  1306. wake_up(&card->wait_q);
  1307. }
  1308. return rc;
  1309. }
  1310. static int qeth_osn_send_ipa_cmd(struct qeth_card *card,
  1311. struct qeth_cmd_buffer *iob, int data_len)
  1312. {
  1313. u16 s1, s2;
  1314. QETH_CARD_TEXT(card, 4, "osndipa");
  1315. qeth_prepare_ipa_cmd(card, iob, QETH_PROT_OSN2);
  1316. s1 = (u16)(IPA_PDU_HEADER_SIZE + data_len);
  1317. s2 = (u16)data_len;
  1318. memcpy(QETH_IPA_PDU_LEN_TOTAL(iob->data), &s1, 2);
  1319. memcpy(QETH_IPA_PDU_LEN_PDU1(iob->data), &s2, 2);
  1320. memcpy(QETH_IPA_PDU_LEN_PDU2(iob->data), &s2, 2);
  1321. memcpy(QETH_IPA_PDU_LEN_PDU3(iob->data), &s2, 2);
  1322. return qeth_osn_send_control_data(card, s1, iob);
  1323. }
  1324. int qeth_osn_assist(struct net_device *dev, void *data, int data_len)
  1325. {
  1326. struct qeth_cmd_buffer *iob;
  1327. struct qeth_card *card;
  1328. int rc;
  1329. if (!dev)
  1330. return -ENODEV;
  1331. card = dev->ml_priv;
  1332. if (!card)
  1333. return -ENODEV;
  1334. QETH_CARD_TEXT(card, 2, "osnsdmc");
  1335. if (!qeth_card_hw_is_reachable(card))
  1336. return -ENODEV;
  1337. iob = qeth_wait_for_buffer(&card->write);
  1338. memcpy(iob->data+IPA_PDU_HEADER_SIZE, data, data_len);
  1339. rc = qeth_osn_send_ipa_cmd(card, iob, data_len);
  1340. return rc;
  1341. }
  1342. EXPORT_SYMBOL(qeth_osn_assist);
  1343. int qeth_osn_register(unsigned char *read_dev_no, struct net_device **dev,
  1344. int (*assist_cb)(struct net_device *, void *),
  1345. int (*data_cb)(struct sk_buff *))
  1346. {
  1347. struct qeth_card *card;
  1348. *dev = qeth_l2_netdev_by_devno(read_dev_no);
  1349. if (*dev == NULL)
  1350. return -ENODEV;
  1351. card = (*dev)->ml_priv;
  1352. if (!card)
  1353. return -ENODEV;
  1354. QETH_CARD_TEXT(card, 2, "osnreg");
  1355. if ((assist_cb == NULL) || (data_cb == NULL))
  1356. return -EINVAL;
  1357. card->osn_info.assist_cb = assist_cb;
  1358. card->osn_info.data_cb = data_cb;
  1359. return 0;
  1360. }
  1361. EXPORT_SYMBOL(qeth_osn_register);
  1362. void qeth_osn_deregister(struct net_device *dev)
  1363. {
  1364. struct qeth_card *card;
  1365. if (!dev)
  1366. return;
  1367. card = dev->ml_priv;
  1368. if (!card)
  1369. return;
  1370. QETH_CARD_TEXT(card, 2, "osndereg");
  1371. card->osn_info.assist_cb = NULL;
  1372. card->osn_info.data_cb = NULL;
  1373. return;
  1374. }
  1375. EXPORT_SYMBOL(qeth_osn_deregister);
  1376. /* SETBRIDGEPORT support, async notifications */
  1377. enum qeth_an_event_type {anev_reg_unreg, anev_abort, anev_reset};
  1378. /**
  1379. * qeth_bridge_emit_host_event() - bridgeport address change notification
  1380. * @card: qeth_card structure pointer, for udev events.
  1381. * @evtype: "normal" register/unregister, or abort, or reset. For abort
  1382. * and reset token and addr_lnid are unused and may be NULL.
  1383. * @code: event bitmask: high order bit 0x80 value 1 means removal of an
  1384. * object, 0 - addition of an object.
  1385. * 0x01 - VLAN, 0x02 - MAC, 0x03 - VLAN and MAC.
  1386. * @token: "network token" structure identifying physical address of the port.
  1387. * @addr_lnid: pointer to structure with MAC address and VLAN ID.
  1388. *
  1389. * This function is called when registrations and deregistrations are
  1390. * reported by the hardware, and also when notifications are enabled -
  1391. * for all currently registered addresses.
  1392. */
  1393. static void qeth_bridge_emit_host_event(struct qeth_card *card,
  1394. enum qeth_an_event_type evtype,
  1395. u8 code, struct net_if_token *token, struct mac_addr_lnid *addr_lnid)
  1396. {
  1397. char str[7][32];
  1398. char *env[8];
  1399. int i = 0;
  1400. switch (evtype) {
  1401. case anev_reg_unreg:
  1402. snprintf(str[i], sizeof(str[i]), "BRIDGEDHOST=%s",
  1403. (code & IPA_ADDR_CHANGE_CODE_REMOVAL)
  1404. ? "deregister" : "register");
  1405. env[i] = str[i]; i++;
  1406. if (code & IPA_ADDR_CHANGE_CODE_VLANID) {
  1407. snprintf(str[i], sizeof(str[i]), "VLAN=%d",
  1408. addr_lnid->lnid);
  1409. env[i] = str[i]; i++;
  1410. }
  1411. if (code & IPA_ADDR_CHANGE_CODE_MACADDR) {
  1412. snprintf(str[i], sizeof(str[i]), "MAC=%pM",
  1413. addr_lnid->mac);
  1414. env[i] = str[i]; i++;
  1415. }
  1416. snprintf(str[i], sizeof(str[i]), "NTOK_BUSID=%x.%x.%04x",
  1417. token->cssid, token->ssid, token->devnum);
  1418. env[i] = str[i]; i++;
  1419. snprintf(str[i], sizeof(str[i]), "NTOK_IID=%02x", token->iid);
  1420. env[i] = str[i]; i++;
  1421. snprintf(str[i], sizeof(str[i]), "NTOK_CHPID=%02x",
  1422. token->chpid);
  1423. env[i] = str[i]; i++;
  1424. snprintf(str[i], sizeof(str[i]), "NTOK_CHID=%04x", token->chid);
  1425. env[i] = str[i]; i++;
  1426. break;
  1427. case anev_abort:
  1428. snprintf(str[i], sizeof(str[i]), "BRIDGEDHOST=abort");
  1429. env[i] = str[i]; i++;
  1430. break;
  1431. case anev_reset:
  1432. snprintf(str[i], sizeof(str[i]), "BRIDGEDHOST=reset");
  1433. env[i] = str[i]; i++;
  1434. break;
  1435. }
  1436. env[i] = NULL;
  1437. kobject_uevent_env(&card->gdev->dev.kobj, KOBJ_CHANGE, env);
  1438. }
  1439. struct qeth_bridge_state_data {
  1440. struct work_struct worker;
  1441. struct qeth_card *card;
  1442. struct qeth_sbp_state_change qports;
  1443. };
  1444. static void qeth_bridge_state_change_worker(struct work_struct *work)
  1445. {
  1446. struct qeth_bridge_state_data *data =
  1447. container_of(work, struct qeth_bridge_state_data, worker);
  1448. /* We are only interested in the first entry - local port */
  1449. struct qeth_sbp_port_entry *entry = &data->qports.entry[0];
  1450. char env_locrem[32];
  1451. char env_role[32];
  1452. char env_state[32];
  1453. char *env[] = {
  1454. env_locrem,
  1455. env_role,
  1456. env_state,
  1457. NULL
  1458. };
  1459. /* Role should not change by itself, but if it did, */
  1460. /* information from the hardware is authoritative. */
  1461. mutex_lock(&data->card->conf_mutex);
  1462. data->card->options.sbp.role = entry->role;
  1463. mutex_unlock(&data->card->conf_mutex);
  1464. snprintf(env_locrem, sizeof(env_locrem), "BRIDGEPORT=statechange");
  1465. snprintf(env_role, sizeof(env_role), "ROLE=%s",
  1466. (entry->role == QETH_SBP_ROLE_NONE) ? "none" :
  1467. (entry->role == QETH_SBP_ROLE_PRIMARY) ? "primary" :
  1468. (entry->role == QETH_SBP_ROLE_SECONDARY) ? "secondary" :
  1469. "<INVALID>");
  1470. snprintf(env_state, sizeof(env_state), "STATE=%s",
  1471. (entry->state == QETH_SBP_STATE_INACTIVE) ? "inactive" :
  1472. (entry->state == QETH_SBP_STATE_STANDBY) ? "standby" :
  1473. (entry->state == QETH_SBP_STATE_ACTIVE) ? "active" :
  1474. "<INVALID>");
  1475. kobject_uevent_env(&data->card->gdev->dev.kobj,
  1476. KOBJ_CHANGE, env);
  1477. kfree(data);
  1478. }
  1479. static void qeth_bridge_state_change(struct qeth_card *card,
  1480. struct qeth_ipa_cmd *cmd)
  1481. {
  1482. struct qeth_sbp_state_change *qports =
  1483. &cmd->data.sbp.data.state_change;
  1484. struct qeth_bridge_state_data *data;
  1485. int extrasize;
  1486. QETH_CARD_TEXT(card, 2, "brstchng");
  1487. if (qports->entry_length != sizeof(struct qeth_sbp_port_entry)) {
  1488. QETH_CARD_TEXT_(card, 2, "BPsz%04x", qports->entry_length);
  1489. return;
  1490. }
  1491. extrasize = sizeof(struct qeth_sbp_port_entry) * qports->num_entries;
  1492. data = kzalloc(sizeof(struct qeth_bridge_state_data) + extrasize,
  1493. GFP_ATOMIC);
  1494. if (!data) {
  1495. QETH_CARD_TEXT(card, 2, "BPSalloc");
  1496. return;
  1497. }
  1498. INIT_WORK(&data->worker, qeth_bridge_state_change_worker);
  1499. data->card = card;
  1500. memcpy(&data->qports, qports,
  1501. sizeof(struct qeth_sbp_state_change) + extrasize);
  1502. queue_work(qeth_wq, &data->worker);
  1503. }
  1504. struct qeth_bridge_host_data {
  1505. struct work_struct worker;
  1506. struct qeth_card *card;
  1507. struct qeth_ipacmd_addr_change hostevs;
  1508. };
  1509. static void qeth_bridge_host_event_worker(struct work_struct *work)
  1510. {
  1511. struct qeth_bridge_host_data *data =
  1512. container_of(work, struct qeth_bridge_host_data, worker);
  1513. int i;
  1514. if (data->hostevs.lost_event_mask) {
  1515. dev_info(&data->card->gdev->dev,
  1516. "Address notification from the Bridge Port stopped %s (%s)\n",
  1517. data->card->dev->name,
  1518. (data->hostevs.lost_event_mask == 0x01)
  1519. ? "Overflow"
  1520. : (data->hostevs.lost_event_mask == 0x02)
  1521. ? "Bridge port state change"
  1522. : "Unknown reason");
  1523. mutex_lock(&data->card->conf_mutex);
  1524. data->card->options.sbp.hostnotification = 0;
  1525. mutex_unlock(&data->card->conf_mutex);
  1526. qeth_bridge_emit_host_event(data->card, anev_abort,
  1527. 0, NULL, NULL);
  1528. } else
  1529. for (i = 0; i < data->hostevs.num_entries; i++) {
  1530. struct qeth_ipacmd_addr_change_entry *entry =
  1531. &data->hostevs.entry[i];
  1532. qeth_bridge_emit_host_event(data->card,
  1533. anev_reg_unreg,
  1534. entry->change_code,
  1535. &entry->token, &entry->addr_lnid);
  1536. }
  1537. kfree(data);
  1538. }
  1539. static void qeth_bridge_host_event(struct qeth_card *card,
  1540. struct qeth_ipa_cmd *cmd)
  1541. {
  1542. struct qeth_ipacmd_addr_change *hostevs =
  1543. &cmd->data.addrchange;
  1544. struct qeth_bridge_host_data *data;
  1545. int extrasize;
  1546. QETH_CARD_TEXT(card, 2, "brhostev");
  1547. if (cmd->hdr.return_code != 0x0000) {
  1548. if (cmd->hdr.return_code == 0x0010) {
  1549. if (hostevs->lost_event_mask == 0x00)
  1550. hostevs->lost_event_mask = 0xff;
  1551. } else {
  1552. QETH_CARD_TEXT_(card, 2, "BPHe%04x",
  1553. cmd->hdr.return_code);
  1554. return;
  1555. }
  1556. }
  1557. extrasize = sizeof(struct qeth_ipacmd_addr_change_entry) *
  1558. hostevs->num_entries;
  1559. data = kzalloc(sizeof(struct qeth_bridge_host_data) + extrasize,
  1560. GFP_ATOMIC);
  1561. if (!data) {
  1562. QETH_CARD_TEXT(card, 2, "BPHalloc");
  1563. return;
  1564. }
  1565. INIT_WORK(&data->worker, qeth_bridge_host_event_worker);
  1566. data->card = card;
  1567. memcpy(&data->hostevs, hostevs,
  1568. sizeof(struct qeth_ipacmd_addr_change) + extrasize);
  1569. queue_work(qeth_wq, &data->worker);
  1570. }
  1571. /* SETBRIDGEPORT support; sending commands */
  1572. struct _qeth_sbp_cbctl {
  1573. u16 ipa_rc;
  1574. u16 cmd_rc;
  1575. union {
  1576. u32 supported;
  1577. struct {
  1578. enum qeth_sbp_roles *role;
  1579. enum qeth_sbp_states *state;
  1580. } qports;
  1581. } data;
  1582. };
  1583. /**
  1584. * qeth_bridgeport_makerc() - derive "traditional" error from hardware codes.
  1585. * @card: qeth_card structure pointer, for debug messages.
  1586. * @cbctl: state structure with hardware return codes.
  1587. * @setcmd: IPA command code
  1588. *
  1589. * Returns negative errno-compatible error indication or 0 on success.
  1590. */
  1591. static int qeth_bridgeport_makerc(struct qeth_card *card,
  1592. struct _qeth_sbp_cbctl *cbctl, enum qeth_ipa_sbp_cmd setcmd)
  1593. {
  1594. int rc;
  1595. int is_iqd = (card->info.type == QETH_CARD_TYPE_IQD);
  1596. if ((is_iqd && (cbctl->ipa_rc == IPA_RC_SUCCESS)) ||
  1597. (!is_iqd && (cbctl->ipa_rc == cbctl->cmd_rc)))
  1598. switch (cbctl->cmd_rc) {
  1599. case 0x0000:
  1600. rc = 0;
  1601. break;
  1602. case 0x2B04:
  1603. case 0x0004:
  1604. rc = -EOPNOTSUPP;
  1605. break;
  1606. case 0x2B0C:
  1607. case 0x000C: /* Not configured as bridge Port */
  1608. rc = -ENODEV; /* maybe not the best code here? */
  1609. dev_err(&card->gdev->dev,
  1610. "The device is not configured as a Bridge Port\n");
  1611. break;
  1612. case 0x2B14:
  1613. case 0x0014: /* Another device is Primary */
  1614. switch (setcmd) {
  1615. case IPA_SBP_SET_PRIMARY_BRIDGE_PORT:
  1616. rc = -EEXIST;
  1617. dev_err(&card->gdev->dev,
  1618. "The LAN already has a primary Bridge Port\n");
  1619. break;
  1620. case IPA_SBP_SET_SECONDARY_BRIDGE_PORT:
  1621. rc = -EBUSY;
  1622. dev_err(&card->gdev->dev,
  1623. "The device is already a primary Bridge Port\n");
  1624. break;
  1625. default:
  1626. rc = -EIO;
  1627. }
  1628. break;
  1629. case 0x2B18:
  1630. case 0x0018: /* This device is currently Secondary */
  1631. rc = -EBUSY;
  1632. dev_err(&card->gdev->dev,
  1633. "The device is already a secondary Bridge Port\n");
  1634. break;
  1635. case 0x2B1C:
  1636. case 0x001C: /* Limit for Secondary devices reached */
  1637. rc = -EEXIST;
  1638. dev_err(&card->gdev->dev,
  1639. "The LAN cannot have more secondary Bridge Ports\n");
  1640. break;
  1641. case 0x2B24:
  1642. case 0x0024: /* This device is currently Primary */
  1643. rc = -EBUSY;
  1644. dev_err(&card->gdev->dev,
  1645. "The device is already a primary Bridge Port\n");
  1646. break;
  1647. case 0x2B20:
  1648. case 0x0020: /* Not authorized by zManager */
  1649. rc = -EACCES;
  1650. dev_err(&card->gdev->dev,
  1651. "The device is not authorized to be a Bridge Port\n");
  1652. break;
  1653. default:
  1654. rc = -EIO;
  1655. }
  1656. else
  1657. switch (cbctl->ipa_rc) {
  1658. case IPA_RC_NOTSUPP:
  1659. rc = -EOPNOTSUPP;
  1660. break;
  1661. case IPA_RC_UNSUPPORTED_COMMAND:
  1662. rc = -EOPNOTSUPP;
  1663. break;
  1664. default:
  1665. rc = -EIO;
  1666. }
  1667. if (rc) {
  1668. QETH_CARD_TEXT_(card, 2, "SBPi%04x", cbctl->ipa_rc);
  1669. QETH_CARD_TEXT_(card, 2, "SBPc%04x", cbctl->cmd_rc);
  1670. }
  1671. return rc;
  1672. }
  1673. static inline int ipa_cmd_sbp(struct qeth_card *card)
  1674. {
  1675. return (card->info.type == QETH_CARD_TYPE_IQD) ?
  1676. IPA_CMD_SETBRIDGEPORT_IQD :
  1677. IPA_CMD_SETBRIDGEPORT_OSA;
  1678. }
  1679. static int qeth_bridgeport_query_support_cb(struct qeth_card *card,
  1680. struct qeth_reply *reply, unsigned long data)
  1681. {
  1682. struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data;
  1683. struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param;
  1684. QETH_CARD_TEXT(card, 2, "brqsupcb");
  1685. cbctl->ipa_rc = cmd->hdr.return_code;
  1686. cbctl->cmd_rc = cmd->data.sbp.hdr.return_code;
  1687. if ((cbctl->ipa_rc == 0) && (cbctl->cmd_rc == 0)) {
  1688. cbctl->data.supported =
  1689. cmd->data.sbp.data.query_cmds_supp.supported_cmds;
  1690. } else {
  1691. cbctl->data.supported = 0;
  1692. }
  1693. return 0;
  1694. }
  1695. /**
  1696. * qeth_bridgeport_query_support() - store bitmask of supported subfunctions.
  1697. * @card: qeth_card structure pointer.
  1698. *
  1699. * Sets bitmask of supported setbridgeport subfunctions in the qeth_card
  1700. * strucutre: card->options.sbp.supported_funcs.
  1701. */
  1702. static void qeth_bridgeport_query_support(struct qeth_card *card)
  1703. {
  1704. struct qeth_cmd_buffer *iob;
  1705. struct qeth_ipa_cmd *cmd;
  1706. struct _qeth_sbp_cbctl cbctl;
  1707. QETH_CARD_TEXT(card, 2, "brqsuppo");
  1708. iob = qeth_get_ipacmd_buffer(card, ipa_cmd_sbp(card), 0);
  1709. if (!iob)
  1710. return;
  1711. cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
  1712. cmd->data.sbp.hdr.cmdlength =
  1713. sizeof(struct qeth_ipacmd_sbp_hdr) +
  1714. sizeof(struct qeth_sbp_query_cmds_supp);
  1715. cmd->data.sbp.hdr.command_code =
  1716. IPA_SBP_QUERY_COMMANDS_SUPPORTED;
  1717. cmd->data.sbp.hdr.used_total = 1;
  1718. cmd->data.sbp.hdr.seq_no = 1;
  1719. if (qeth_send_ipa_cmd(card, iob, qeth_bridgeport_query_support_cb,
  1720. (void *)&cbctl) ||
  1721. qeth_bridgeport_makerc(card, &cbctl,
  1722. IPA_SBP_QUERY_COMMANDS_SUPPORTED)) {
  1723. /* non-zero makerc signifies failure, and produce messages */
  1724. card->options.sbp.role = QETH_SBP_ROLE_NONE;
  1725. return;
  1726. }
  1727. card->options.sbp.supported_funcs = cbctl.data.supported;
  1728. }
  1729. static int qeth_bridgeport_query_ports_cb(struct qeth_card *card,
  1730. struct qeth_reply *reply, unsigned long data)
  1731. {
  1732. struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data;
  1733. struct qeth_sbp_query_ports *qports = &cmd->data.sbp.data.query_ports;
  1734. struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param;
  1735. QETH_CARD_TEXT(card, 2, "brqprtcb");
  1736. cbctl->ipa_rc = cmd->hdr.return_code;
  1737. cbctl->cmd_rc = cmd->data.sbp.hdr.return_code;
  1738. if ((cbctl->ipa_rc != 0) || (cbctl->cmd_rc != 0))
  1739. return 0;
  1740. if (qports->entry_length != sizeof(struct qeth_sbp_port_entry)) {
  1741. cbctl->cmd_rc = 0xffff;
  1742. QETH_CARD_TEXT_(card, 2, "SBPs%04x", qports->entry_length);
  1743. return 0;
  1744. }
  1745. /* first entry contains the state of the local port */
  1746. if (qports->num_entries > 0) {
  1747. if (cbctl->data.qports.role)
  1748. *cbctl->data.qports.role = qports->entry[0].role;
  1749. if (cbctl->data.qports.state)
  1750. *cbctl->data.qports.state = qports->entry[0].state;
  1751. }
  1752. return 0;
  1753. }
  1754. /**
  1755. * qeth_bridgeport_query_ports() - query local bridgeport status.
  1756. * @card: qeth_card structure pointer.
  1757. * @role: Role of the port: 0-none, 1-primary, 2-secondary.
  1758. * @state: State of the port: 0-inactive, 1-standby, 2-active.
  1759. *
  1760. * Returns negative errno-compatible error indication or 0 on success.
  1761. *
  1762. * 'role' and 'state' are not updated in case of hardware operation failure.
  1763. */
  1764. int qeth_bridgeport_query_ports(struct qeth_card *card,
  1765. enum qeth_sbp_roles *role, enum qeth_sbp_states *state)
  1766. {
  1767. int rc = 0;
  1768. struct qeth_cmd_buffer *iob;
  1769. struct qeth_ipa_cmd *cmd;
  1770. struct _qeth_sbp_cbctl cbctl = {
  1771. .data = {
  1772. .qports = {
  1773. .role = role,
  1774. .state = state,
  1775. },
  1776. },
  1777. };
  1778. QETH_CARD_TEXT(card, 2, "brqports");
  1779. if (!(card->options.sbp.supported_funcs & IPA_SBP_QUERY_BRIDGE_PORTS))
  1780. return -EOPNOTSUPP;
  1781. iob = qeth_get_ipacmd_buffer(card, ipa_cmd_sbp(card), 0);
  1782. if (!iob)
  1783. return -ENOMEM;
  1784. cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
  1785. cmd->data.sbp.hdr.cmdlength =
  1786. sizeof(struct qeth_ipacmd_sbp_hdr);
  1787. cmd->data.sbp.hdr.command_code =
  1788. IPA_SBP_QUERY_BRIDGE_PORTS;
  1789. cmd->data.sbp.hdr.used_total = 1;
  1790. cmd->data.sbp.hdr.seq_no = 1;
  1791. rc = qeth_send_ipa_cmd(card, iob, qeth_bridgeport_query_ports_cb,
  1792. (void *)&cbctl);
  1793. if (rc < 0)
  1794. return rc;
  1795. return qeth_bridgeport_makerc(card, &cbctl, IPA_SBP_QUERY_BRIDGE_PORTS);
  1796. }
  1797. EXPORT_SYMBOL_GPL(qeth_bridgeport_query_ports);
  1798. static int qeth_bridgeport_set_cb(struct qeth_card *card,
  1799. struct qeth_reply *reply, unsigned long data)
  1800. {
  1801. struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *)data;
  1802. struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param;
  1803. QETH_CARD_TEXT(card, 2, "brsetrcb");
  1804. cbctl->ipa_rc = cmd->hdr.return_code;
  1805. cbctl->cmd_rc = cmd->data.sbp.hdr.return_code;
  1806. return 0;
  1807. }
  1808. /**
  1809. * qeth_bridgeport_setrole() - Assign primary role to the port.
  1810. * @card: qeth_card structure pointer.
  1811. * @role: Role to assign.
  1812. *
  1813. * Returns negative errno-compatible error indication or 0 on success.
  1814. */
  1815. int qeth_bridgeport_setrole(struct qeth_card *card, enum qeth_sbp_roles role)
  1816. {
  1817. int rc = 0;
  1818. int cmdlength;
  1819. struct qeth_cmd_buffer *iob;
  1820. struct qeth_ipa_cmd *cmd;
  1821. struct _qeth_sbp_cbctl cbctl;
  1822. enum qeth_ipa_sbp_cmd setcmd;
  1823. QETH_CARD_TEXT(card, 2, "brsetrol");
  1824. switch (role) {
  1825. case QETH_SBP_ROLE_NONE:
  1826. setcmd = IPA_SBP_RESET_BRIDGE_PORT_ROLE;
  1827. cmdlength = sizeof(struct qeth_ipacmd_sbp_hdr) +
  1828. sizeof(struct qeth_sbp_reset_role);
  1829. break;
  1830. case QETH_SBP_ROLE_PRIMARY:
  1831. setcmd = IPA_SBP_SET_PRIMARY_BRIDGE_PORT;
  1832. cmdlength = sizeof(struct qeth_ipacmd_sbp_hdr) +
  1833. sizeof(struct qeth_sbp_set_primary);
  1834. break;
  1835. case QETH_SBP_ROLE_SECONDARY:
  1836. setcmd = IPA_SBP_SET_SECONDARY_BRIDGE_PORT;
  1837. cmdlength = sizeof(struct qeth_ipacmd_sbp_hdr) +
  1838. sizeof(struct qeth_sbp_set_secondary);
  1839. break;
  1840. default:
  1841. return -EINVAL;
  1842. }
  1843. if (!(card->options.sbp.supported_funcs & setcmd))
  1844. return -EOPNOTSUPP;
  1845. iob = qeth_get_ipacmd_buffer(card, ipa_cmd_sbp(card), 0);
  1846. if (!iob)
  1847. return -ENOMEM;
  1848. cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
  1849. cmd->data.sbp.hdr.cmdlength = cmdlength;
  1850. cmd->data.sbp.hdr.command_code = setcmd;
  1851. cmd->data.sbp.hdr.used_total = 1;
  1852. cmd->data.sbp.hdr.seq_no = 1;
  1853. rc = qeth_send_ipa_cmd(card, iob, qeth_bridgeport_set_cb,
  1854. (void *)&cbctl);
  1855. if (rc < 0)
  1856. return rc;
  1857. return qeth_bridgeport_makerc(card, &cbctl, setcmd);
  1858. }
  1859. /**
  1860. * qeth_anset_makerc() - derive "traditional" error from hardware codes.
  1861. * @card: qeth_card structure pointer, for debug messages.
  1862. *
  1863. * Returns negative errno-compatible error indication or 0 on success.
  1864. */
  1865. static int qeth_anset_makerc(struct qeth_card *card, int pnso_rc, u16 response)
  1866. {
  1867. int rc;
  1868. if (pnso_rc == 0)
  1869. switch (response) {
  1870. case 0x0001:
  1871. rc = 0;
  1872. break;
  1873. case 0x0004:
  1874. case 0x0100:
  1875. case 0x0106:
  1876. rc = -EOPNOTSUPP;
  1877. dev_err(&card->gdev->dev,
  1878. "Setting address notification failed\n");
  1879. break;
  1880. case 0x0107:
  1881. rc = -EAGAIN;
  1882. break;
  1883. default:
  1884. rc = -EIO;
  1885. }
  1886. else
  1887. rc = -EIO;
  1888. if (rc) {
  1889. QETH_CARD_TEXT_(card, 2, "SBPp%04x", pnso_rc);
  1890. QETH_CARD_TEXT_(card, 2, "SBPr%04x", response);
  1891. }
  1892. return rc;
  1893. }
  1894. static void qeth_bridgeport_an_set_cb(void *priv,
  1895. enum qdio_brinfo_entry_type type, void *entry)
  1896. {
  1897. struct qeth_card *card = (struct qeth_card *)priv;
  1898. struct qdio_brinfo_entry_l2 *l2entry;
  1899. u8 code;
  1900. if (type != l2_addr_lnid) {
  1901. WARN_ON_ONCE(1);
  1902. return;
  1903. }
  1904. l2entry = (struct qdio_brinfo_entry_l2 *)entry;
  1905. code = IPA_ADDR_CHANGE_CODE_MACADDR;
  1906. if (l2entry->addr_lnid.lnid)
  1907. code |= IPA_ADDR_CHANGE_CODE_VLANID;
  1908. qeth_bridge_emit_host_event(card, anev_reg_unreg, code,
  1909. (struct net_if_token *)&l2entry->nit,
  1910. (struct mac_addr_lnid *)&l2entry->addr_lnid);
  1911. }
  1912. /**
  1913. * qeth_bridgeport_an_set() - Enable or disable bridgeport address notification
  1914. * @card: qeth_card structure pointer.
  1915. * @enable: 0 - disable, non-zero - enable notifications
  1916. *
  1917. * Returns negative errno-compatible error indication or 0 on success.
  1918. *
  1919. * On enable, emits a series of address notifications udev events for all
  1920. * currently registered hosts.
  1921. */
  1922. int qeth_bridgeport_an_set(struct qeth_card *card, int enable)
  1923. {
  1924. int rc;
  1925. u16 response;
  1926. struct ccw_device *ddev;
  1927. struct subchannel_id schid;
  1928. if (!card)
  1929. return -EINVAL;
  1930. if (!card->options.sbp.supported_funcs)
  1931. return -EOPNOTSUPP;
  1932. ddev = CARD_DDEV(card);
  1933. ccw_device_get_schid(ddev, &schid);
  1934. if (enable) {
  1935. qeth_bridge_emit_host_event(card, anev_reset, 0, NULL, NULL);
  1936. rc = qdio_pnso_brinfo(schid, 1, &response,
  1937. qeth_bridgeport_an_set_cb, card);
  1938. } else
  1939. rc = qdio_pnso_brinfo(schid, 0, &response, NULL, NULL);
  1940. return qeth_anset_makerc(card, rc, response);
  1941. }
  1942. EXPORT_SYMBOL_GPL(qeth_bridgeport_an_set);
  1943. module_init(qeth_l2_init);
  1944. module_exit(qeth_l2_exit);
  1945. MODULE_AUTHOR("Frank Blaschka <frank.blaschka@de.ibm.com>");
  1946. MODULE_DESCRIPTION("qeth layer 2 discipline");
  1947. MODULE_LICENSE("GPL");