qeth_l2_main.c 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173
  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 void qeth_l2_stop_card(struct qeth_card *card, int recovery_mode)
  366. {
  367. QETH_DBF_TEXT(SETUP , 2, "stopcard");
  368. QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *));
  369. qeth_set_allowed_threads(card, 0, 1);
  370. if (card->read.state == CH_STATE_UP &&
  371. card->write.state == CH_STATE_UP &&
  372. (card->state == CARD_STATE_UP)) {
  373. if (recovery_mode &&
  374. card->info.type != QETH_CARD_TYPE_OSN) {
  375. qeth_l2_stop(card->dev);
  376. } else {
  377. rtnl_lock();
  378. dev_close(card->dev);
  379. rtnl_unlock();
  380. }
  381. card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED;
  382. card->state = CARD_STATE_SOFTSETUP;
  383. }
  384. if (card->state == CARD_STATE_SOFTSETUP) {
  385. qeth_l2_del_all_macs(card, 0);
  386. qeth_clear_ipacmd_list(card);
  387. card->state = CARD_STATE_HARDSETUP;
  388. }
  389. if (card->state == CARD_STATE_HARDSETUP) {
  390. qeth_qdio_clear_card(card, 0);
  391. qeth_clear_qdio_buffers(card);
  392. qeth_clear_working_pool_list(card);
  393. card->state = CARD_STATE_DOWN;
  394. }
  395. if (card->state == CARD_STATE_DOWN) {
  396. qeth_clear_cmd_buffers(&card->read);
  397. qeth_clear_cmd_buffers(&card->write);
  398. }
  399. }
  400. static int qeth_l2_process_inbound_buffer(struct qeth_card *card,
  401. int budget, int *done)
  402. {
  403. int work_done = 0;
  404. struct sk_buff *skb;
  405. struct qeth_hdr *hdr;
  406. unsigned int len;
  407. *done = 0;
  408. WARN_ON_ONCE(!budget);
  409. while (budget) {
  410. skb = qeth_core_get_next_skb(card,
  411. &card->qdio.in_q->bufs[card->rx.b_index],
  412. &card->rx.b_element, &card->rx.e_offset, &hdr);
  413. if (!skb) {
  414. *done = 1;
  415. break;
  416. }
  417. skb->dev = card->dev;
  418. switch (hdr->hdr.l2.id) {
  419. case QETH_HEADER_TYPE_LAYER2:
  420. skb->pkt_type = PACKET_HOST;
  421. skb->protocol = eth_type_trans(skb, skb->dev);
  422. if ((card->dev->features & NETIF_F_RXCSUM)
  423. && ((hdr->hdr.l2.flags[1] &
  424. (QETH_HDR_EXT_CSUM_HDR_REQ |
  425. QETH_HDR_EXT_CSUM_TRANSP_REQ)) ==
  426. (QETH_HDR_EXT_CSUM_HDR_REQ |
  427. QETH_HDR_EXT_CSUM_TRANSP_REQ)))
  428. skb->ip_summed = CHECKSUM_UNNECESSARY;
  429. else
  430. skb->ip_summed = CHECKSUM_NONE;
  431. if (skb->protocol == htons(ETH_P_802_2))
  432. *((__u32 *)skb->cb) = ++card->seqno.pkt_seqno;
  433. len = skb->len;
  434. napi_gro_receive(&card->napi, skb);
  435. break;
  436. case QETH_HEADER_TYPE_OSN:
  437. if (card->info.type == QETH_CARD_TYPE_OSN) {
  438. skb_push(skb, sizeof(struct qeth_hdr));
  439. skb_copy_to_linear_data(skb, hdr,
  440. sizeof(struct qeth_hdr));
  441. len = skb->len;
  442. card->osn_info.data_cb(skb);
  443. break;
  444. }
  445. /* else unknown */
  446. default:
  447. dev_kfree_skb_any(skb);
  448. QETH_CARD_TEXT(card, 3, "inbunkno");
  449. QETH_DBF_HEX(CTRL, 3, hdr, QETH_DBF_CTRL_LEN);
  450. continue;
  451. }
  452. work_done++;
  453. budget--;
  454. card->stats.rx_packets++;
  455. card->stats.rx_bytes += len;
  456. }
  457. return work_done;
  458. }
  459. static int qeth_l2_poll(struct napi_struct *napi, int budget)
  460. {
  461. struct qeth_card *card = container_of(napi, struct qeth_card, napi);
  462. int work_done = 0;
  463. struct qeth_qdio_buffer *buffer;
  464. int done;
  465. int new_budget = budget;
  466. if (card->options.performance_stats) {
  467. card->perf_stats.inbound_cnt++;
  468. card->perf_stats.inbound_start_time = qeth_get_micros();
  469. }
  470. while (1) {
  471. if (!card->rx.b_count) {
  472. card->rx.qdio_err = 0;
  473. card->rx.b_count = qdio_get_next_buffers(
  474. card->data.ccwdev, 0, &card->rx.b_index,
  475. &card->rx.qdio_err);
  476. if (card->rx.b_count <= 0) {
  477. card->rx.b_count = 0;
  478. break;
  479. }
  480. card->rx.b_element =
  481. &card->qdio.in_q->bufs[card->rx.b_index]
  482. .buffer->element[0];
  483. card->rx.e_offset = 0;
  484. }
  485. while (card->rx.b_count) {
  486. buffer = &card->qdio.in_q->bufs[card->rx.b_index];
  487. if (!(card->rx.qdio_err &&
  488. qeth_check_qdio_errors(card, buffer->buffer,
  489. card->rx.qdio_err, "qinerr")))
  490. work_done += qeth_l2_process_inbound_buffer(
  491. card, new_budget, &done);
  492. else
  493. done = 1;
  494. if (done) {
  495. if (card->options.performance_stats)
  496. card->perf_stats.bufs_rec++;
  497. qeth_put_buffer_pool_entry(card,
  498. buffer->pool_entry);
  499. qeth_queue_input_buffer(card, card->rx.b_index);
  500. card->rx.b_count--;
  501. if (card->rx.b_count) {
  502. card->rx.b_index =
  503. (card->rx.b_index + 1) %
  504. QDIO_MAX_BUFFERS_PER_Q;
  505. card->rx.b_element =
  506. &card->qdio.in_q
  507. ->bufs[card->rx.b_index]
  508. .buffer->element[0];
  509. card->rx.e_offset = 0;
  510. }
  511. }
  512. if (work_done >= budget)
  513. goto out;
  514. else
  515. new_budget = budget - work_done;
  516. }
  517. }
  518. napi_complete(napi);
  519. if (qdio_start_irq(card->data.ccwdev, 0))
  520. napi_schedule(&card->napi);
  521. out:
  522. if (card->options.performance_stats)
  523. card->perf_stats.inbound_time += qeth_get_micros() -
  524. card->perf_stats.inbound_start_time;
  525. return work_done;
  526. }
  527. static int qeth_l2_send_setdelmac(struct qeth_card *card, __u8 *mac,
  528. enum qeth_ipa_cmds ipacmd)
  529. {
  530. struct qeth_ipa_cmd *cmd;
  531. struct qeth_cmd_buffer *iob;
  532. QETH_CARD_TEXT(card, 2, "L2sdmac");
  533. iob = qeth_get_ipacmd_buffer(card, ipacmd, QETH_PROT_IPV4);
  534. if (!iob)
  535. return -ENOMEM;
  536. cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
  537. cmd->data.setdelmac.mac_length = OSA_ADDR_LEN;
  538. memcpy(&cmd->data.setdelmac.mac, mac, OSA_ADDR_LEN);
  539. return qeth_send_ipa_cmd(card, iob, NULL, NULL);
  540. }
  541. static int qeth_l2_send_setmac(struct qeth_card *card, __u8 *mac)
  542. {
  543. int rc;
  544. QETH_CARD_TEXT(card, 2, "L2Setmac");
  545. rc = qeth_setdel_makerc(card, qeth_l2_send_setdelmac(card, mac,
  546. IPA_CMD_SETVMAC));
  547. if (rc == 0) {
  548. card->info.mac_bits |= QETH_LAYER2_MAC_REGISTERED;
  549. memcpy(card->dev->dev_addr, mac, OSA_ADDR_LEN);
  550. dev_info(&card->gdev->dev,
  551. "MAC address %pM successfully registered on device %s\n",
  552. card->dev->dev_addr, card->dev->name);
  553. } else {
  554. card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED;
  555. switch (rc) {
  556. case -EEXIST:
  557. dev_warn(&card->gdev->dev,
  558. "MAC address %pM already exists\n", mac);
  559. break;
  560. case -EPERM:
  561. dev_warn(&card->gdev->dev,
  562. "MAC address %pM is not authorized\n", mac);
  563. break;
  564. }
  565. }
  566. return rc;
  567. }
  568. static int qeth_l2_send_delmac(struct qeth_card *card, __u8 *mac)
  569. {
  570. int rc;
  571. QETH_CARD_TEXT(card, 2, "L2Delmac");
  572. if (!(card->info.mac_bits & QETH_LAYER2_MAC_REGISTERED))
  573. return 0;
  574. rc = qeth_setdel_makerc(card, qeth_l2_send_setdelmac(card, mac,
  575. IPA_CMD_DELVMAC));
  576. if (rc == 0)
  577. card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED;
  578. return rc;
  579. }
  580. static int qeth_l2_request_initial_mac(struct qeth_card *card)
  581. {
  582. int rc = 0;
  583. char vendor_pre[] = {0x02, 0x00, 0x00};
  584. QETH_DBF_TEXT(SETUP, 2, "doL2init");
  585. QETH_DBF_TEXT_(SETUP, 2, "doL2%s", CARD_BUS_ID(card));
  586. if (qeth_is_supported(card, IPA_SETADAPTERPARMS)) {
  587. rc = qeth_query_setadapterparms(card);
  588. if (rc) {
  589. QETH_DBF_MESSAGE(2, "could not query adapter "
  590. "parameters on device %s: x%x\n",
  591. CARD_BUS_ID(card), rc);
  592. }
  593. }
  594. if (card->info.type == QETH_CARD_TYPE_IQD ||
  595. card->info.type == QETH_CARD_TYPE_OSM ||
  596. card->info.type == QETH_CARD_TYPE_OSX ||
  597. card->info.guestlan) {
  598. rc = qeth_setadpparms_change_macaddr(card);
  599. if (rc) {
  600. QETH_DBF_MESSAGE(2, "couldn't get MAC address on "
  601. "device %s: x%x\n", CARD_BUS_ID(card), rc);
  602. QETH_DBF_TEXT_(SETUP, 2, "1err%04x", rc);
  603. return rc;
  604. }
  605. QETH_DBF_HEX(SETUP, 2, card->dev->dev_addr, OSA_ADDR_LEN);
  606. } else {
  607. eth_random_addr(card->dev->dev_addr);
  608. memcpy(card->dev->dev_addr, vendor_pre, 3);
  609. }
  610. return 0;
  611. }
  612. static int qeth_l2_set_mac_address(struct net_device *dev, void *p)
  613. {
  614. struct sockaddr *addr = p;
  615. struct qeth_card *card = dev->ml_priv;
  616. int rc = 0;
  617. QETH_CARD_TEXT(card, 3, "setmac");
  618. if (qeth_l2_verify_dev(dev) != QETH_REAL_CARD) {
  619. QETH_CARD_TEXT(card, 3, "setmcINV");
  620. return -EOPNOTSUPP;
  621. }
  622. if (card->info.type == QETH_CARD_TYPE_OSN ||
  623. card->info.type == QETH_CARD_TYPE_OSM ||
  624. card->info.type == QETH_CARD_TYPE_OSX) {
  625. QETH_CARD_TEXT(card, 3, "setmcTYP");
  626. return -EOPNOTSUPP;
  627. }
  628. QETH_CARD_HEX(card, 3, addr->sa_data, OSA_ADDR_LEN);
  629. if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) {
  630. QETH_CARD_TEXT(card, 3, "setmcREC");
  631. return -ERESTARTSYS;
  632. }
  633. rc = qeth_l2_send_delmac(card, &card->dev->dev_addr[0]);
  634. if (!rc || (rc == -ENOENT))
  635. rc = qeth_l2_send_setmac(card, addr->sa_data);
  636. return rc ? -EINVAL : 0;
  637. }
  638. static void qeth_promisc_to_bridge(struct qeth_card *card)
  639. {
  640. struct net_device *dev = card->dev;
  641. enum qeth_ipa_promisc_modes promisc_mode;
  642. int role;
  643. int rc;
  644. QETH_CARD_TEXT(card, 3, "pmisc2br");
  645. if (!card->options.sbp.reflect_promisc)
  646. return;
  647. promisc_mode = (dev->flags & IFF_PROMISC) ? SET_PROMISC_MODE_ON
  648. : SET_PROMISC_MODE_OFF;
  649. if (promisc_mode == card->info.promisc_mode)
  650. return;
  651. if (promisc_mode == SET_PROMISC_MODE_ON) {
  652. if (card->options.sbp.reflect_promisc_primary)
  653. role = QETH_SBP_ROLE_PRIMARY;
  654. else
  655. role = QETH_SBP_ROLE_SECONDARY;
  656. } else
  657. role = QETH_SBP_ROLE_NONE;
  658. rc = qeth_bridgeport_setrole(card, role);
  659. QETH_DBF_TEXT_(SETUP, 2, "bpm%c%04x",
  660. (promisc_mode == SET_PROMISC_MODE_ON) ? '+' : '-', rc);
  661. if (!rc) {
  662. card->options.sbp.role = role;
  663. card->info.promisc_mode = promisc_mode;
  664. }
  665. }
  666. /* New MAC address is added to the hash table and marked to be written on card
  667. * only if there is not in the hash table storage already
  668. *
  669. */
  670. static void
  671. qeth_l2_add_mac(struct qeth_card *card, struct netdev_hw_addr *ha, u8 is_uc)
  672. {
  673. struct qeth_mac *mac;
  674. hash_for_each_possible(card->mac_htable, mac, hnode,
  675. qeth_l2_mac_hash(ha->addr)) {
  676. if (is_uc == mac->is_uc &&
  677. !memcmp(ha->addr, mac->mac_addr, OSA_ADDR_LEN)) {
  678. mac->disp_flag = QETH_DISP_ADDR_DO_NOTHING;
  679. return;
  680. }
  681. }
  682. mac = kzalloc(sizeof(struct qeth_mac), GFP_ATOMIC);
  683. if (!mac)
  684. return;
  685. memcpy(mac->mac_addr, ha->addr, OSA_ADDR_LEN);
  686. mac->is_uc = is_uc;
  687. mac->disp_flag = QETH_DISP_ADDR_ADD;
  688. hash_add(card->mac_htable, &mac->hnode,
  689. qeth_l2_mac_hash(mac->mac_addr));
  690. }
  691. static void qeth_l2_set_rx_mode(struct net_device *dev)
  692. {
  693. struct qeth_card *card = dev->ml_priv;
  694. struct netdev_hw_addr *ha;
  695. struct qeth_mac *mac;
  696. struct hlist_node *tmp;
  697. int i;
  698. int rc;
  699. if (card->info.type == QETH_CARD_TYPE_OSN)
  700. return;
  701. QETH_CARD_TEXT(card, 3, "setmulti");
  702. if (qeth_threads_running(card, QETH_RECOVER_THREAD) &&
  703. (card->state != CARD_STATE_UP))
  704. return;
  705. spin_lock_bh(&card->mclock);
  706. netdev_for_each_mc_addr(ha, dev)
  707. qeth_l2_add_mac(card, ha, 0);
  708. netdev_for_each_uc_addr(ha, dev)
  709. qeth_l2_add_mac(card, ha, 1);
  710. hash_for_each_safe(card->mac_htable, i, tmp, mac, hnode) {
  711. if (mac->disp_flag == QETH_DISP_ADDR_DELETE) {
  712. if (!mac->is_uc)
  713. rc = qeth_l2_send_delgroupmac(card,
  714. mac->mac_addr);
  715. else {
  716. rc = qeth_l2_send_setdelmac(card, mac->mac_addr,
  717. IPA_CMD_DELVMAC);
  718. }
  719. hash_del(&mac->hnode);
  720. kfree(mac);
  721. } else if (mac->disp_flag == QETH_DISP_ADDR_ADD) {
  722. rc = qeth_l2_write_mac(card, mac);
  723. if (rc) {
  724. hash_del(&mac->hnode);
  725. kfree(mac);
  726. } else
  727. mac->disp_flag = QETH_DISP_ADDR_DELETE;
  728. } else
  729. mac->disp_flag = QETH_DISP_ADDR_DELETE;
  730. }
  731. spin_unlock_bh(&card->mclock);
  732. if (qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE))
  733. qeth_setadp_promisc_mode(card);
  734. else
  735. qeth_promisc_to_bridge(card);
  736. }
  737. static int qeth_l2_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
  738. {
  739. int rc;
  740. struct qeth_hdr *hdr = NULL;
  741. int elements = 0;
  742. struct qeth_card *card = dev->ml_priv;
  743. struct sk_buff *new_skb = skb;
  744. int cast_type = qeth_l2_get_cast_type(card, skb);
  745. struct qeth_qdio_out_q *queue;
  746. int tx_bytes = skb->len;
  747. int data_offset = -1;
  748. int elements_needed = 0;
  749. int hd_len = 0;
  750. int nr_frags;
  751. if (card->qdio.do_prio_queueing || (cast_type &&
  752. card->info.is_multicast_different))
  753. queue = card->qdio.out_qs[qeth_get_priority_queue(card, skb,
  754. qeth_get_ip_version(skb), cast_type)];
  755. else
  756. queue = card->qdio.out_qs[card->qdio.default_out_queue];
  757. if ((card->state != CARD_STATE_UP) || !card->lan_online) {
  758. card->stats.tx_carrier_errors++;
  759. goto tx_drop;
  760. }
  761. if ((card->info.type == QETH_CARD_TYPE_OSN) &&
  762. (skb->protocol == htons(ETH_P_IPV6)))
  763. goto tx_drop;
  764. if (card->options.performance_stats) {
  765. card->perf_stats.outbound_cnt++;
  766. card->perf_stats.outbound_start_time = qeth_get_micros();
  767. }
  768. netif_stop_queue(dev);
  769. /* fix hardware limitation: as long as we do not have sbal
  770. * chaining we can not send long frag lists
  771. */
  772. if ((card->info.type != QETH_CARD_TYPE_IQD) &&
  773. !qeth_get_elements_no(card, new_skb, 0, 0)) {
  774. int lin_rc = skb_linearize(new_skb);
  775. if (card->options.performance_stats) {
  776. if (lin_rc)
  777. card->perf_stats.tx_linfail++;
  778. else
  779. card->perf_stats.tx_lin++;
  780. }
  781. if (lin_rc)
  782. goto tx_drop;
  783. }
  784. if (card->info.type == QETH_CARD_TYPE_OSN)
  785. hdr = (struct qeth_hdr *)skb->data;
  786. else {
  787. if (card->info.type == QETH_CARD_TYPE_IQD) {
  788. new_skb = skb;
  789. data_offset = ETH_HLEN;
  790. hd_len = ETH_HLEN;
  791. hdr = kmem_cache_alloc(qeth_core_header_cache,
  792. GFP_ATOMIC);
  793. if (!hdr)
  794. goto tx_drop;
  795. elements_needed++;
  796. skb_reset_mac_header(new_skb);
  797. qeth_l2_fill_header(card, hdr, new_skb, cast_type);
  798. hdr->hdr.l2.pkt_length = new_skb->len;
  799. memcpy(((char *)hdr) + sizeof(struct qeth_hdr),
  800. skb_mac_header(new_skb), ETH_HLEN);
  801. } else {
  802. /* create a clone with writeable headroom */
  803. new_skb = skb_realloc_headroom(skb,
  804. sizeof(struct qeth_hdr));
  805. if (!new_skb)
  806. goto tx_drop;
  807. hdr = (struct qeth_hdr *)skb_push(new_skb,
  808. sizeof(struct qeth_hdr));
  809. skb_set_mac_header(new_skb, sizeof(struct qeth_hdr));
  810. qeth_l2_fill_header(card, hdr, new_skb, cast_type);
  811. if (new_skb->ip_summed == CHECKSUM_PARTIAL)
  812. qeth_l2_hdr_csum(card, hdr, new_skb);
  813. }
  814. }
  815. elements = qeth_get_elements_no(card, new_skb, elements_needed,
  816. (data_offset > 0) ? data_offset : 0);
  817. if (!elements) {
  818. if (data_offset >= 0)
  819. kmem_cache_free(qeth_core_header_cache, hdr);
  820. goto tx_drop;
  821. }
  822. if (card->info.type != QETH_CARD_TYPE_IQD) {
  823. if (qeth_hdr_chk_and_bounce(new_skb, &hdr,
  824. sizeof(struct qeth_hdr_layer2)))
  825. goto tx_drop;
  826. rc = qeth_do_send_packet(card, queue, new_skb, hdr,
  827. elements);
  828. } else
  829. rc = qeth_do_send_packet_fast(card, queue, new_skb, hdr,
  830. elements, data_offset, hd_len);
  831. if (!rc) {
  832. card->stats.tx_packets++;
  833. card->stats.tx_bytes += tx_bytes;
  834. if (card->options.performance_stats) {
  835. nr_frags = skb_shinfo(new_skb)->nr_frags;
  836. if (nr_frags) {
  837. card->perf_stats.sg_skbs_sent++;
  838. /* nr_frags + skb->data */
  839. card->perf_stats.sg_frags_sent += nr_frags + 1;
  840. }
  841. }
  842. if (new_skb != skb)
  843. dev_kfree_skb_any(skb);
  844. rc = NETDEV_TX_OK;
  845. } else {
  846. if (data_offset >= 0)
  847. kmem_cache_free(qeth_core_header_cache, hdr);
  848. if (rc == -EBUSY) {
  849. if (new_skb != skb)
  850. dev_kfree_skb_any(new_skb);
  851. return NETDEV_TX_BUSY;
  852. } else
  853. goto tx_drop;
  854. }
  855. netif_wake_queue(dev);
  856. if (card->options.performance_stats)
  857. card->perf_stats.outbound_time += qeth_get_micros() -
  858. card->perf_stats.outbound_start_time;
  859. return rc;
  860. tx_drop:
  861. card->stats.tx_dropped++;
  862. card->stats.tx_errors++;
  863. if ((new_skb != skb) && new_skb)
  864. dev_kfree_skb_any(new_skb);
  865. dev_kfree_skb_any(skb);
  866. netif_wake_queue(dev);
  867. return NETDEV_TX_OK;
  868. }
  869. static int __qeth_l2_open(struct net_device *dev)
  870. {
  871. struct qeth_card *card = dev->ml_priv;
  872. int rc = 0;
  873. QETH_CARD_TEXT(card, 4, "qethopen");
  874. if (card->state == CARD_STATE_UP)
  875. return rc;
  876. if (card->state != CARD_STATE_SOFTSETUP)
  877. return -ENODEV;
  878. if ((card->info.type != QETH_CARD_TYPE_OSN) &&
  879. (!(card->info.mac_bits & QETH_LAYER2_MAC_REGISTERED))) {
  880. QETH_CARD_TEXT(card, 4, "nomacadr");
  881. return -EPERM;
  882. }
  883. card->data.state = CH_STATE_UP;
  884. card->state = CARD_STATE_UP;
  885. netif_start_queue(dev);
  886. if (qdio_stop_irq(card->data.ccwdev, 0) >= 0) {
  887. napi_enable(&card->napi);
  888. napi_schedule(&card->napi);
  889. } else
  890. rc = -EIO;
  891. return rc;
  892. }
  893. static int qeth_l2_open(struct net_device *dev)
  894. {
  895. struct qeth_card *card = dev->ml_priv;
  896. QETH_CARD_TEXT(card, 5, "qethope_");
  897. if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) {
  898. QETH_CARD_TEXT(card, 3, "openREC");
  899. return -ERESTARTSYS;
  900. }
  901. return __qeth_l2_open(dev);
  902. }
  903. static int qeth_l2_stop(struct net_device *dev)
  904. {
  905. struct qeth_card *card = dev->ml_priv;
  906. QETH_CARD_TEXT(card, 4, "qethstop");
  907. netif_tx_disable(dev);
  908. if (card->state == CARD_STATE_UP) {
  909. card->state = CARD_STATE_SOFTSETUP;
  910. napi_disable(&card->napi);
  911. }
  912. return 0;
  913. }
  914. static const struct device_type qeth_l2_devtype = {
  915. .name = "qeth_layer2",
  916. .groups = qeth_l2_attr_groups,
  917. };
  918. static int qeth_l2_probe_device(struct ccwgroup_device *gdev)
  919. {
  920. struct qeth_card *card = dev_get_drvdata(&gdev->dev);
  921. int rc;
  922. if (gdev->dev.type == &qeth_generic_devtype) {
  923. rc = qeth_l2_create_device_attributes(&gdev->dev);
  924. if (rc)
  925. return rc;
  926. }
  927. INIT_LIST_HEAD(&card->vid_list);
  928. hash_init(card->mac_htable);
  929. card->options.layer2 = 1;
  930. card->info.hwtrap = 0;
  931. return 0;
  932. }
  933. static void qeth_l2_remove_device(struct ccwgroup_device *cgdev)
  934. {
  935. struct qeth_card *card = dev_get_drvdata(&cgdev->dev);
  936. if (cgdev->dev.type == &qeth_generic_devtype)
  937. qeth_l2_remove_device_attributes(&cgdev->dev);
  938. qeth_set_allowed_threads(card, 0, 1);
  939. wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0);
  940. if (cgdev->state == CCWGROUP_ONLINE)
  941. qeth_l2_set_offline(cgdev);
  942. if (card->dev) {
  943. unregister_netdev(card->dev);
  944. free_netdev(card->dev);
  945. card->dev = NULL;
  946. }
  947. return;
  948. }
  949. static const struct ethtool_ops qeth_l2_ethtool_ops = {
  950. .get_link = ethtool_op_get_link,
  951. .get_strings = qeth_core_get_strings,
  952. .get_ethtool_stats = qeth_core_get_ethtool_stats,
  953. .get_sset_count = qeth_core_get_sset_count,
  954. .get_drvinfo = qeth_core_get_drvinfo,
  955. .get_settings = qeth_core_ethtool_get_settings,
  956. };
  957. static const struct ethtool_ops qeth_l2_osn_ops = {
  958. .get_strings = qeth_core_get_strings,
  959. .get_ethtool_stats = qeth_core_get_ethtool_stats,
  960. .get_sset_count = qeth_core_get_sset_count,
  961. .get_drvinfo = qeth_core_get_drvinfo,
  962. };
  963. static const struct net_device_ops qeth_l2_netdev_ops = {
  964. .ndo_open = qeth_l2_open,
  965. .ndo_stop = qeth_l2_stop,
  966. .ndo_get_stats = qeth_get_stats,
  967. .ndo_start_xmit = qeth_l2_hard_start_xmit,
  968. .ndo_features_check = qeth_features_check,
  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_fix_features,
  978. .ndo_set_features = qeth_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_SG;
  1009. card->dev->vlan_features = NETIF_F_SG;
  1010. card->dev->features |= NETIF_F_SG;
  1011. /* OSA 3S and earlier has no RX/TX support */
  1012. if (qeth_is_supported(card, IPA_OUTBOUND_CHECKSUM)) {
  1013. card->dev->hw_features |= NETIF_F_IP_CSUM;
  1014. card->dev->vlan_features |= NETIF_F_IP_CSUM;
  1015. }
  1016. if (qeth_is_supported(card, IPA_INBOUND_CHECKSUM)) {
  1017. card->dev->hw_features |= NETIF_F_RXCSUM;
  1018. card->dev->vlan_features |= NETIF_F_RXCSUM;
  1019. }
  1020. }
  1021. card->info.broadcast_capable = 1;
  1022. qeth_l2_request_initial_mac(card);
  1023. SET_NETDEV_DEV(card->dev, &card->gdev->dev);
  1024. netif_napi_add(card->dev, &card->napi, qeth_l2_poll, QETH_NAPI_WEIGHT);
  1025. netif_carrier_off(card->dev);
  1026. return register_netdev(card->dev);
  1027. }
  1028. static int qeth_l2_start_ipassists(struct qeth_card *card)
  1029. {
  1030. /* configure isolation level */
  1031. if (qeth_set_access_ctrl_online(card, 0))
  1032. return -ENODEV;
  1033. return 0;
  1034. }
  1035. static int __qeth_l2_set_online(struct ccwgroup_device *gdev, int recovery_mode)
  1036. {
  1037. struct qeth_card *card = dev_get_drvdata(&gdev->dev);
  1038. int rc = 0;
  1039. enum qeth_card_states recover_flag;
  1040. mutex_lock(&card->discipline_mutex);
  1041. mutex_lock(&card->conf_mutex);
  1042. QETH_DBF_TEXT(SETUP, 2, "setonlin");
  1043. QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *));
  1044. recover_flag = card->state;
  1045. rc = qeth_core_hardsetup_card(card);
  1046. if (rc) {
  1047. QETH_DBF_TEXT_(SETUP, 2, "2err%04x", rc);
  1048. rc = -ENODEV;
  1049. goto out_remove;
  1050. }
  1051. qeth_bridgeport_query_support(card);
  1052. if (card->options.sbp.supported_funcs)
  1053. dev_info(&card->gdev->dev,
  1054. "The device represents a Bridge Capable Port\n");
  1055. qeth_trace_features(card);
  1056. if (!card->dev && qeth_l2_setup_netdev(card)) {
  1057. rc = -ENODEV;
  1058. goto out_remove;
  1059. }
  1060. if (card->info.type != QETH_CARD_TYPE_OSN)
  1061. qeth_l2_send_setmac(card, &card->dev->dev_addr[0]);
  1062. if (qeth_is_diagass_supported(card, QETH_DIAGS_CMD_TRAP)) {
  1063. if (card->info.hwtrap &&
  1064. qeth_hw_trap(card, QETH_DIAGS_TRAP_ARM))
  1065. card->info.hwtrap = 0;
  1066. } else
  1067. card->info.hwtrap = 0;
  1068. qeth_l2_setup_bridgeport_attrs(card);
  1069. card->state = CARD_STATE_HARDSETUP;
  1070. memset(&card->rx, 0, sizeof(struct qeth_rx));
  1071. qeth_print_status_message(card);
  1072. /* softsetup */
  1073. QETH_DBF_TEXT(SETUP, 2, "softsetp");
  1074. if ((card->info.type == QETH_CARD_TYPE_OSD) ||
  1075. (card->info.type == QETH_CARD_TYPE_OSX)) {
  1076. rc = qeth_l2_start_ipassists(card);
  1077. if (rc)
  1078. goto out_remove;
  1079. }
  1080. if (card->info.type != QETH_CARD_TYPE_OSN &&
  1081. card->info.type != QETH_CARD_TYPE_OSM)
  1082. qeth_l2_process_vlans(card);
  1083. netif_tx_disable(card->dev);
  1084. rc = qeth_init_qdio_queues(card);
  1085. if (rc) {
  1086. QETH_DBF_TEXT_(SETUP, 2, "6err%d", rc);
  1087. rc = -ENODEV;
  1088. goto out_remove;
  1089. }
  1090. card->state = CARD_STATE_SOFTSETUP;
  1091. if (card->lan_online)
  1092. netif_carrier_on(card->dev);
  1093. else
  1094. netif_carrier_off(card->dev);
  1095. qeth_set_allowed_threads(card, 0xffffffff, 0);
  1096. if (recover_flag == CARD_STATE_RECOVER) {
  1097. if (recovery_mode &&
  1098. card->info.type != QETH_CARD_TYPE_OSN) {
  1099. __qeth_l2_open(card->dev);
  1100. } else {
  1101. rtnl_lock();
  1102. dev_open(card->dev);
  1103. rtnl_unlock();
  1104. }
  1105. /* this also sets saved unicast addresses */
  1106. qeth_l2_set_rx_mode(card->dev);
  1107. rtnl_lock();
  1108. qeth_recover_features(card->dev);
  1109. rtnl_unlock();
  1110. }
  1111. /* let user_space know that device is online */
  1112. kobject_uevent(&gdev->dev.kobj, KOBJ_CHANGE);
  1113. mutex_unlock(&card->conf_mutex);
  1114. mutex_unlock(&card->discipline_mutex);
  1115. return 0;
  1116. out_remove:
  1117. qeth_l2_stop_card(card, 0);
  1118. ccw_device_set_offline(CARD_DDEV(card));
  1119. ccw_device_set_offline(CARD_WDEV(card));
  1120. ccw_device_set_offline(CARD_RDEV(card));
  1121. qdio_free(CARD_DDEV(card));
  1122. if (recover_flag == CARD_STATE_RECOVER)
  1123. card->state = CARD_STATE_RECOVER;
  1124. else
  1125. card->state = CARD_STATE_DOWN;
  1126. mutex_unlock(&card->conf_mutex);
  1127. mutex_unlock(&card->discipline_mutex);
  1128. return rc;
  1129. }
  1130. static int qeth_l2_set_online(struct ccwgroup_device *gdev)
  1131. {
  1132. return __qeth_l2_set_online(gdev, 0);
  1133. }
  1134. static int __qeth_l2_set_offline(struct ccwgroup_device *cgdev,
  1135. int recovery_mode)
  1136. {
  1137. struct qeth_card *card = dev_get_drvdata(&cgdev->dev);
  1138. int rc = 0, rc2 = 0, rc3 = 0;
  1139. enum qeth_card_states recover_flag;
  1140. mutex_lock(&card->discipline_mutex);
  1141. mutex_lock(&card->conf_mutex);
  1142. QETH_DBF_TEXT(SETUP, 3, "setoffl");
  1143. QETH_DBF_HEX(SETUP, 3, &card, sizeof(void *));
  1144. if (card->dev && netif_carrier_ok(card->dev))
  1145. netif_carrier_off(card->dev);
  1146. recover_flag = card->state;
  1147. if ((!recovery_mode && card->info.hwtrap) || card->info.hwtrap == 2) {
  1148. qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM);
  1149. card->info.hwtrap = 1;
  1150. }
  1151. qeth_l2_stop_card(card, recovery_mode);
  1152. rc = ccw_device_set_offline(CARD_DDEV(card));
  1153. rc2 = ccw_device_set_offline(CARD_WDEV(card));
  1154. rc3 = ccw_device_set_offline(CARD_RDEV(card));
  1155. if (!rc)
  1156. rc = (rc2) ? rc2 : rc3;
  1157. if (rc)
  1158. QETH_DBF_TEXT_(SETUP, 2, "1err%d", rc);
  1159. qdio_free(CARD_DDEV(card));
  1160. if (recover_flag == CARD_STATE_UP)
  1161. card->state = CARD_STATE_RECOVER;
  1162. /* let user_space know that device is offline */
  1163. kobject_uevent(&cgdev->dev.kobj, KOBJ_CHANGE);
  1164. mutex_unlock(&card->conf_mutex);
  1165. mutex_unlock(&card->discipline_mutex);
  1166. return 0;
  1167. }
  1168. static int qeth_l2_set_offline(struct ccwgroup_device *cgdev)
  1169. {
  1170. return __qeth_l2_set_offline(cgdev, 0);
  1171. }
  1172. static int qeth_l2_recover(void *ptr)
  1173. {
  1174. struct qeth_card *card;
  1175. int rc = 0;
  1176. card = (struct qeth_card *) ptr;
  1177. QETH_CARD_TEXT(card, 2, "recover1");
  1178. if (!qeth_do_run_thread(card, QETH_RECOVER_THREAD))
  1179. return 0;
  1180. QETH_CARD_TEXT(card, 2, "recover2");
  1181. dev_warn(&card->gdev->dev,
  1182. "A recovery process has been started for the device\n");
  1183. qeth_set_recovery_task(card);
  1184. __qeth_l2_set_offline(card->gdev, 1);
  1185. rc = __qeth_l2_set_online(card->gdev, 1);
  1186. if (!rc)
  1187. dev_info(&card->gdev->dev,
  1188. "Device successfully recovered!\n");
  1189. else {
  1190. qeth_close_dev(card);
  1191. dev_warn(&card->gdev->dev, "The qeth device driver "
  1192. "failed to recover an error on the device\n");
  1193. }
  1194. qeth_clear_recovery_task(card);
  1195. qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD);
  1196. qeth_clear_thread_running_bit(card, QETH_RECOVER_THREAD);
  1197. return 0;
  1198. }
  1199. static int __init qeth_l2_init(void)
  1200. {
  1201. pr_info("register layer 2 discipline\n");
  1202. return 0;
  1203. }
  1204. static void __exit qeth_l2_exit(void)
  1205. {
  1206. pr_info("unregister layer 2 discipline\n");
  1207. }
  1208. static void qeth_l2_shutdown(struct ccwgroup_device *gdev)
  1209. {
  1210. struct qeth_card *card = dev_get_drvdata(&gdev->dev);
  1211. qeth_set_allowed_threads(card, 0, 1);
  1212. if ((gdev->state == CCWGROUP_ONLINE) && card->info.hwtrap)
  1213. qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM);
  1214. qeth_qdio_clear_card(card, 0);
  1215. qeth_clear_qdio_buffers(card);
  1216. qdio_free(CARD_DDEV(card));
  1217. }
  1218. static int qeth_l2_pm_suspend(struct ccwgroup_device *gdev)
  1219. {
  1220. struct qeth_card *card = dev_get_drvdata(&gdev->dev);
  1221. if (card->dev)
  1222. netif_device_detach(card->dev);
  1223. qeth_set_allowed_threads(card, 0, 1);
  1224. wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0);
  1225. if (gdev->state == CCWGROUP_OFFLINE)
  1226. return 0;
  1227. if (card->state == CARD_STATE_UP) {
  1228. if (card->info.hwtrap)
  1229. qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM);
  1230. __qeth_l2_set_offline(card->gdev, 1);
  1231. } else
  1232. __qeth_l2_set_offline(card->gdev, 0);
  1233. return 0;
  1234. }
  1235. static int qeth_l2_pm_resume(struct ccwgroup_device *gdev)
  1236. {
  1237. struct qeth_card *card = dev_get_drvdata(&gdev->dev);
  1238. int rc = 0;
  1239. if (gdev->state == CCWGROUP_OFFLINE)
  1240. goto out;
  1241. if (card->state == CARD_STATE_RECOVER) {
  1242. rc = __qeth_l2_set_online(card->gdev, 1);
  1243. if (rc) {
  1244. rtnl_lock();
  1245. dev_close(card->dev);
  1246. rtnl_unlock();
  1247. }
  1248. } else
  1249. rc = __qeth_l2_set_online(card->gdev, 0);
  1250. out:
  1251. qeth_set_allowed_threads(card, 0xffffffff, 0);
  1252. if (card->dev)
  1253. netif_device_attach(card->dev);
  1254. if (rc)
  1255. dev_warn(&card->gdev->dev, "The qeth device driver "
  1256. "failed to recover an error on the device\n");
  1257. return rc;
  1258. }
  1259. /* Returns zero if the command is successfully "consumed" */
  1260. static int qeth_l2_control_event(struct qeth_card *card,
  1261. struct qeth_ipa_cmd *cmd)
  1262. {
  1263. switch (cmd->hdr.command) {
  1264. case IPA_CMD_SETBRIDGEPORT_OSA:
  1265. case IPA_CMD_SETBRIDGEPORT_IQD:
  1266. if (cmd->data.sbp.hdr.command_code ==
  1267. IPA_SBP_BRIDGE_PORT_STATE_CHANGE) {
  1268. qeth_bridge_state_change(card, cmd);
  1269. return 0;
  1270. } else
  1271. return 1;
  1272. case IPA_CMD_ADDRESS_CHANGE_NOTIF:
  1273. qeth_bridge_host_event(card, cmd);
  1274. return 0;
  1275. default:
  1276. return 1;
  1277. }
  1278. }
  1279. struct qeth_discipline qeth_l2_discipline = {
  1280. .devtype = &qeth_l2_devtype,
  1281. .start_poll = qeth_qdio_start_poll,
  1282. .input_handler = (qdio_handler_t *) qeth_qdio_input_handler,
  1283. .output_handler = (qdio_handler_t *) qeth_qdio_output_handler,
  1284. .recover = qeth_l2_recover,
  1285. .setup = qeth_l2_probe_device,
  1286. .remove = qeth_l2_remove_device,
  1287. .set_online = qeth_l2_set_online,
  1288. .set_offline = qeth_l2_set_offline,
  1289. .shutdown = qeth_l2_shutdown,
  1290. .freeze = qeth_l2_pm_suspend,
  1291. .thaw = qeth_l2_pm_resume,
  1292. .restore = qeth_l2_pm_resume,
  1293. .control_event_handler = qeth_l2_control_event,
  1294. };
  1295. EXPORT_SYMBOL_GPL(qeth_l2_discipline);
  1296. static int qeth_osn_send_control_data(struct qeth_card *card, int len,
  1297. struct qeth_cmd_buffer *iob)
  1298. {
  1299. unsigned long flags;
  1300. int rc = 0;
  1301. QETH_CARD_TEXT(card, 5, "osndctrd");
  1302. wait_event(card->wait_q,
  1303. atomic_cmpxchg(&card->write.irq_pending, 0, 1) == 0);
  1304. qeth_prepare_control_data(card, len, iob);
  1305. QETH_CARD_TEXT(card, 6, "osnoirqp");
  1306. spin_lock_irqsave(get_ccwdev_lock(card->write.ccwdev), flags);
  1307. rc = ccw_device_start(card->write.ccwdev, &card->write.ccw,
  1308. (addr_t) iob, 0, 0);
  1309. spin_unlock_irqrestore(get_ccwdev_lock(card->write.ccwdev), flags);
  1310. if (rc) {
  1311. QETH_DBF_MESSAGE(2, "qeth_osn_send_control_data: "
  1312. "ccw_device_start rc = %i\n", rc);
  1313. QETH_CARD_TEXT_(card, 2, " err%d", rc);
  1314. qeth_release_buffer(iob->channel, iob);
  1315. atomic_set(&card->write.irq_pending, 0);
  1316. wake_up(&card->wait_q);
  1317. }
  1318. return rc;
  1319. }
  1320. static int qeth_osn_send_ipa_cmd(struct qeth_card *card,
  1321. struct qeth_cmd_buffer *iob, int data_len)
  1322. {
  1323. u16 s1, s2;
  1324. QETH_CARD_TEXT(card, 4, "osndipa");
  1325. qeth_prepare_ipa_cmd(card, iob, QETH_PROT_OSN2);
  1326. s1 = (u16)(IPA_PDU_HEADER_SIZE + data_len);
  1327. s2 = (u16)data_len;
  1328. memcpy(QETH_IPA_PDU_LEN_TOTAL(iob->data), &s1, 2);
  1329. memcpy(QETH_IPA_PDU_LEN_PDU1(iob->data), &s2, 2);
  1330. memcpy(QETH_IPA_PDU_LEN_PDU2(iob->data), &s2, 2);
  1331. memcpy(QETH_IPA_PDU_LEN_PDU3(iob->data), &s2, 2);
  1332. return qeth_osn_send_control_data(card, s1, iob);
  1333. }
  1334. int qeth_osn_assist(struct net_device *dev, void *data, int data_len)
  1335. {
  1336. struct qeth_cmd_buffer *iob;
  1337. struct qeth_card *card;
  1338. int rc;
  1339. if (!dev)
  1340. return -ENODEV;
  1341. card = dev->ml_priv;
  1342. if (!card)
  1343. return -ENODEV;
  1344. QETH_CARD_TEXT(card, 2, "osnsdmc");
  1345. if (!qeth_card_hw_is_reachable(card))
  1346. return -ENODEV;
  1347. iob = qeth_wait_for_buffer(&card->write);
  1348. memcpy(iob->data+IPA_PDU_HEADER_SIZE, data, data_len);
  1349. rc = qeth_osn_send_ipa_cmd(card, iob, data_len);
  1350. return rc;
  1351. }
  1352. EXPORT_SYMBOL(qeth_osn_assist);
  1353. int qeth_osn_register(unsigned char *read_dev_no, struct net_device **dev,
  1354. int (*assist_cb)(struct net_device *, void *),
  1355. int (*data_cb)(struct sk_buff *))
  1356. {
  1357. struct qeth_card *card;
  1358. *dev = qeth_l2_netdev_by_devno(read_dev_no);
  1359. if (*dev == NULL)
  1360. return -ENODEV;
  1361. card = (*dev)->ml_priv;
  1362. if (!card)
  1363. return -ENODEV;
  1364. QETH_CARD_TEXT(card, 2, "osnreg");
  1365. if ((assist_cb == NULL) || (data_cb == NULL))
  1366. return -EINVAL;
  1367. card->osn_info.assist_cb = assist_cb;
  1368. card->osn_info.data_cb = data_cb;
  1369. return 0;
  1370. }
  1371. EXPORT_SYMBOL(qeth_osn_register);
  1372. void qeth_osn_deregister(struct net_device *dev)
  1373. {
  1374. struct qeth_card *card;
  1375. if (!dev)
  1376. return;
  1377. card = dev->ml_priv;
  1378. if (!card)
  1379. return;
  1380. QETH_CARD_TEXT(card, 2, "osndereg");
  1381. card->osn_info.assist_cb = NULL;
  1382. card->osn_info.data_cb = NULL;
  1383. return;
  1384. }
  1385. EXPORT_SYMBOL(qeth_osn_deregister);
  1386. /* SETBRIDGEPORT support, async notifications */
  1387. enum qeth_an_event_type {anev_reg_unreg, anev_abort, anev_reset};
  1388. /**
  1389. * qeth_bridge_emit_host_event() - bridgeport address change notification
  1390. * @card: qeth_card structure pointer, for udev events.
  1391. * @evtype: "normal" register/unregister, or abort, or reset. For abort
  1392. * and reset token and addr_lnid are unused and may be NULL.
  1393. * @code: event bitmask: high order bit 0x80 value 1 means removal of an
  1394. * object, 0 - addition of an object.
  1395. * 0x01 - VLAN, 0x02 - MAC, 0x03 - VLAN and MAC.
  1396. * @token: "network token" structure identifying physical address of the port.
  1397. * @addr_lnid: pointer to structure with MAC address and VLAN ID.
  1398. *
  1399. * This function is called when registrations and deregistrations are
  1400. * reported by the hardware, and also when notifications are enabled -
  1401. * for all currently registered addresses.
  1402. */
  1403. static void qeth_bridge_emit_host_event(struct qeth_card *card,
  1404. enum qeth_an_event_type evtype,
  1405. u8 code, struct net_if_token *token, struct mac_addr_lnid *addr_lnid)
  1406. {
  1407. char str[7][32];
  1408. char *env[8];
  1409. int i = 0;
  1410. switch (evtype) {
  1411. case anev_reg_unreg:
  1412. snprintf(str[i], sizeof(str[i]), "BRIDGEDHOST=%s",
  1413. (code & IPA_ADDR_CHANGE_CODE_REMOVAL)
  1414. ? "deregister" : "register");
  1415. env[i] = str[i]; i++;
  1416. if (code & IPA_ADDR_CHANGE_CODE_VLANID) {
  1417. snprintf(str[i], sizeof(str[i]), "VLAN=%d",
  1418. addr_lnid->lnid);
  1419. env[i] = str[i]; i++;
  1420. }
  1421. if (code & IPA_ADDR_CHANGE_CODE_MACADDR) {
  1422. snprintf(str[i], sizeof(str[i]), "MAC=%pM",
  1423. addr_lnid->mac);
  1424. env[i] = str[i]; i++;
  1425. }
  1426. snprintf(str[i], sizeof(str[i]), "NTOK_BUSID=%x.%x.%04x",
  1427. token->cssid, token->ssid, token->devnum);
  1428. env[i] = str[i]; i++;
  1429. snprintf(str[i], sizeof(str[i]), "NTOK_IID=%02x", token->iid);
  1430. env[i] = str[i]; i++;
  1431. snprintf(str[i], sizeof(str[i]), "NTOK_CHPID=%02x",
  1432. token->chpid);
  1433. env[i] = str[i]; i++;
  1434. snprintf(str[i], sizeof(str[i]), "NTOK_CHID=%04x", token->chid);
  1435. env[i] = str[i]; i++;
  1436. break;
  1437. case anev_abort:
  1438. snprintf(str[i], sizeof(str[i]), "BRIDGEDHOST=abort");
  1439. env[i] = str[i]; i++;
  1440. break;
  1441. case anev_reset:
  1442. snprintf(str[i], sizeof(str[i]), "BRIDGEDHOST=reset");
  1443. env[i] = str[i]; i++;
  1444. break;
  1445. }
  1446. env[i] = NULL;
  1447. kobject_uevent_env(&card->gdev->dev.kobj, KOBJ_CHANGE, env);
  1448. }
  1449. struct qeth_bridge_state_data {
  1450. struct work_struct worker;
  1451. struct qeth_card *card;
  1452. struct qeth_sbp_state_change qports;
  1453. };
  1454. static void qeth_bridge_state_change_worker(struct work_struct *work)
  1455. {
  1456. struct qeth_bridge_state_data *data =
  1457. container_of(work, struct qeth_bridge_state_data, worker);
  1458. /* We are only interested in the first entry - local port */
  1459. struct qeth_sbp_port_entry *entry = &data->qports.entry[0];
  1460. char env_locrem[32];
  1461. char env_role[32];
  1462. char env_state[32];
  1463. char *env[] = {
  1464. env_locrem,
  1465. env_role,
  1466. env_state,
  1467. NULL
  1468. };
  1469. /* Role should not change by itself, but if it did, */
  1470. /* information from the hardware is authoritative. */
  1471. mutex_lock(&data->card->conf_mutex);
  1472. data->card->options.sbp.role = entry->role;
  1473. mutex_unlock(&data->card->conf_mutex);
  1474. snprintf(env_locrem, sizeof(env_locrem), "BRIDGEPORT=statechange");
  1475. snprintf(env_role, sizeof(env_role), "ROLE=%s",
  1476. (entry->role == QETH_SBP_ROLE_NONE) ? "none" :
  1477. (entry->role == QETH_SBP_ROLE_PRIMARY) ? "primary" :
  1478. (entry->role == QETH_SBP_ROLE_SECONDARY) ? "secondary" :
  1479. "<INVALID>");
  1480. snprintf(env_state, sizeof(env_state), "STATE=%s",
  1481. (entry->state == QETH_SBP_STATE_INACTIVE) ? "inactive" :
  1482. (entry->state == QETH_SBP_STATE_STANDBY) ? "standby" :
  1483. (entry->state == QETH_SBP_STATE_ACTIVE) ? "active" :
  1484. "<INVALID>");
  1485. kobject_uevent_env(&data->card->gdev->dev.kobj,
  1486. KOBJ_CHANGE, env);
  1487. kfree(data);
  1488. }
  1489. static void qeth_bridge_state_change(struct qeth_card *card,
  1490. struct qeth_ipa_cmd *cmd)
  1491. {
  1492. struct qeth_sbp_state_change *qports =
  1493. &cmd->data.sbp.data.state_change;
  1494. struct qeth_bridge_state_data *data;
  1495. int extrasize;
  1496. QETH_CARD_TEXT(card, 2, "brstchng");
  1497. if (qports->entry_length != sizeof(struct qeth_sbp_port_entry)) {
  1498. QETH_CARD_TEXT_(card, 2, "BPsz%04x", qports->entry_length);
  1499. return;
  1500. }
  1501. extrasize = sizeof(struct qeth_sbp_port_entry) * qports->num_entries;
  1502. data = kzalloc(sizeof(struct qeth_bridge_state_data) + extrasize,
  1503. GFP_ATOMIC);
  1504. if (!data) {
  1505. QETH_CARD_TEXT(card, 2, "BPSalloc");
  1506. return;
  1507. }
  1508. INIT_WORK(&data->worker, qeth_bridge_state_change_worker);
  1509. data->card = card;
  1510. memcpy(&data->qports, qports,
  1511. sizeof(struct qeth_sbp_state_change) + extrasize);
  1512. queue_work(qeth_wq, &data->worker);
  1513. }
  1514. struct qeth_bridge_host_data {
  1515. struct work_struct worker;
  1516. struct qeth_card *card;
  1517. struct qeth_ipacmd_addr_change hostevs;
  1518. };
  1519. static void qeth_bridge_host_event_worker(struct work_struct *work)
  1520. {
  1521. struct qeth_bridge_host_data *data =
  1522. container_of(work, struct qeth_bridge_host_data, worker);
  1523. int i;
  1524. if (data->hostevs.lost_event_mask) {
  1525. dev_info(&data->card->gdev->dev,
  1526. "Address notification from the Bridge Port stopped %s (%s)\n",
  1527. data->card->dev->name,
  1528. (data->hostevs.lost_event_mask == 0x01)
  1529. ? "Overflow"
  1530. : (data->hostevs.lost_event_mask == 0x02)
  1531. ? "Bridge port state change"
  1532. : "Unknown reason");
  1533. mutex_lock(&data->card->conf_mutex);
  1534. data->card->options.sbp.hostnotification = 0;
  1535. mutex_unlock(&data->card->conf_mutex);
  1536. qeth_bridge_emit_host_event(data->card, anev_abort,
  1537. 0, NULL, NULL);
  1538. } else
  1539. for (i = 0; i < data->hostevs.num_entries; i++) {
  1540. struct qeth_ipacmd_addr_change_entry *entry =
  1541. &data->hostevs.entry[i];
  1542. qeth_bridge_emit_host_event(data->card,
  1543. anev_reg_unreg,
  1544. entry->change_code,
  1545. &entry->token, &entry->addr_lnid);
  1546. }
  1547. kfree(data);
  1548. }
  1549. static void qeth_bridge_host_event(struct qeth_card *card,
  1550. struct qeth_ipa_cmd *cmd)
  1551. {
  1552. struct qeth_ipacmd_addr_change *hostevs =
  1553. &cmd->data.addrchange;
  1554. struct qeth_bridge_host_data *data;
  1555. int extrasize;
  1556. QETH_CARD_TEXT(card, 2, "brhostev");
  1557. if (cmd->hdr.return_code != 0x0000) {
  1558. if (cmd->hdr.return_code == 0x0010) {
  1559. if (hostevs->lost_event_mask == 0x00)
  1560. hostevs->lost_event_mask = 0xff;
  1561. } else {
  1562. QETH_CARD_TEXT_(card, 2, "BPHe%04x",
  1563. cmd->hdr.return_code);
  1564. return;
  1565. }
  1566. }
  1567. extrasize = sizeof(struct qeth_ipacmd_addr_change_entry) *
  1568. hostevs->num_entries;
  1569. data = kzalloc(sizeof(struct qeth_bridge_host_data) + extrasize,
  1570. GFP_ATOMIC);
  1571. if (!data) {
  1572. QETH_CARD_TEXT(card, 2, "BPHalloc");
  1573. return;
  1574. }
  1575. INIT_WORK(&data->worker, qeth_bridge_host_event_worker);
  1576. data->card = card;
  1577. memcpy(&data->hostevs, hostevs,
  1578. sizeof(struct qeth_ipacmd_addr_change) + extrasize);
  1579. queue_work(qeth_wq, &data->worker);
  1580. }
  1581. /* SETBRIDGEPORT support; sending commands */
  1582. struct _qeth_sbp_cbctl {
  1583. u16 ipa_rc;
  1584. u16 cmd_rc;
  1585. union {
  1586. u32 supported;
  1587. struct {
  1588. enum qeth_sbp_roles *role;
  1589. enum qeth_sbp_states *state;
  1590. } qports;
  1591. } data;
  1592. };
  1593. /**
  1594. * qeth_bridgeport_makerc() - derive "traditional" error from hardware codes.
  1595. * @card: qeth_card structure pointer, for debug messages.
  1596. * @cbctl: state structure with hardware return codes.
  1597. * @setcmd: IPA command code
  1598. *
  1599. * Returns negative errno-compatible error indication or 0 on success.
  1600. */
  1601. static int qeth_bridgeport_makerc(struct qeth_card *card,
  1602. struct _qeth_sbp_cbctl *cbctl, enum qeth_ipa_sbp_cmd setcmd)
  1603. {
  1604. int rc;
  1605. int is_iqd = (card->info.type == QETH_CARD_TYPE_IQD);
  1606. if ((is_iqd && (cbctl->ipa_rc == IPA_RC_SUCCESS)) ||
  1607. (!is_iqd && (cbctl->ipa_rc == cbctl->cmd_rc)))
  1608. switch (cbctl->cmd_rc) {
  1609. case 0x0000:
  1610. rc = 0;
  1611. break;
  1612. case 0x2B04:
  1613. case 0x0004:
  1614. rc = -EOPNOTSUPP;
  1615. break;
  1616. case 0x2B0C:
  1617. case 0x000C: /* Not configured as bridge Port */
  1618. rc = -ENODEV; /* maybe not the best code here? */
  1619. dev_err(&card->gdev->dev,
  1620. "The device is not configured as a Bridge Port\n");
  1621. break;
  1622. case 0x2B10:
  1623. case 0x0010: /* OS mismatch */
  1624. rc = -EPERM;
  1625. dev_err(&card->gdev->dev,
  1626. "A Bridge Port is already configured by a different operating system\n");
  1627. break;
  1628. case 0x2B14:
  1629. case 0x0014: /* Another device is Primary */
  1630. switch (setcmd) {
  1631. case IPA_SBP_SET_PRIMARY_BRIDGE_PORT:
  1632. rc = -EEXIST;
  1633. dev_err(&card->gdev->dev,
  1634. "The LAN already has a primary Bridge Port\n");
  1635. break;
  1636. case IPA_SBP_SET_SECONDARY_BRIDGE_PORT:
  1637. rc = -EBUSY;
  1638. dev_err(&card->gdev->dev,
  1639. "The device is already a primary Bridge Port\n");
  1640. break;
  1641. default:
  1642. rc = -EIO;
  1643. }
  1644. break;
  1645. case 0x2B18:
  1646. case 0x0018: /* This device is currently Secondary */
  1647. rc = -EBUSY;
  1648. dev_err(&card->gdev->dev,
  1649. "The device is already a secondary Bridge Port\n");
  1650. break;
  1651. case 0x2B1C:
  1652. case 0x001C: /* Limit for Secondary devices reached */
  1653. rc = -EEXIST;
  1654. dev_err(&card->gdev->dev,
  1655. "The LAN cannot have more secondary Bridge Ports\n");
  1656. break;
  1657. case 0x2B24:
  1658. case 0x0024: /* This device is currently Primary */
  1659. rc = -EBUSY;
  1660. dev_err(&card->gdev->dev,
  1661. "The device is already a primary Bridge Port\n");
  1662. break;
  1663. case 0x2B20:
  1664. case 0x0020: /* Not authorized by zManager */
  1665. rc = -EACCES;
  1666. dev_err(&card->gdev->dev,
  1667. "The device is not authorized to be a Bridge Port\n");
  1668. break;
  1669. default:
  1670. rc = -EIO;
  1671. }
  1672. else
  1673. switch (cbctl->ipa_rc) {
  1674. case IPA_RC_NOTSUPP:
  1675. rc = -EOPNOTSUPP;
  1676. break;
  1677. case IPA_RC_UNSUPPORTED_COMMAND:
  1678. rc = -EOPNOTSUPP;
  1679. break;
  1680. default:
  1681. rc = -EIO;
  1682. }
  1683. if (rc) {
  1684. QETH_CARD_TEXT_(card, 2, "SBPi%04x", cbctl->ipa_rc);
  1685. QETH_CARD_TEXT_(card, 2, "SBPc%04x", cbctl->cmd_rc);
  1686. }
  1687. return rc;
  1688. }
  1689. static inline int ipa_cmd_sbp(struct qeth_card *card)
  1690. {
  1691. return (card->info.type == QETH_CARD_TYPE_IQD) ?
  1692. IPA_CMD_SETBRIDGEPORT_IQD :
  1693. IPA_CMD_SETBRIDGEPORT_OSA;
  1694. }
  1695. static int qeth_bridgeport_query_support_cb(struct qeth_card *card,
  1696. struct qeth_reply *reply, unsigned long data)
  1697. {
  1698. struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data;
  1699. struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param;
  1700. QETH_CARD_TEXT(card, 2, "brqsupcb");
  1701. cbctl->ipa_rc = cmd->hdr.return_code;
  1702. cbctl->cmd_rc = cmd->data.sbp.hdr.return_code;
  1703. if ((cbctl->ipa_rc == 0) && (cbctl->cmd_rc == 0)) {
  1704. cbctl->data.supported =
  1705. cmd->data.sbp.data.query_cmds_supp.supported_cmds;
  1706. } else {
  1707. cbctl->data.supported = 0;
  1708. }
  1709. return 0;
  1710. }
  1711. /**
  1712. * qeth_bridgeport_query_support() - store bitmask of supported subfunctions.
  1713. * @card: qeth_card structure pointer.
  1714. *
  1715. * Sets bitmask of supported setbridgeport subfunctions in the qeth_card
  1716. * strucutre: card->options.sbp.supported_funcs.
  1717. */
  1718. static void qeth_bridgeport_query_support(struct qeth_card *card)
  1719. {
  1720. struct qeth_cmd_buffer *iob;
  1721. struct qeth_ipa_cmd *cmd;
  1722. struct _qeth_sbp_cbctl cbctl;
  1723. QETH_CARD_TEXT(card, 2, "brqsuppo");
  1724. iob = qeth_get_ipacmd_buffer(card, ipa_cmd_sbp(card), 0);
  1725. if (!iob)
  1726. return;
  1727. cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
  1728. cmd->data.sbp.hdr.cmdlength =
  1729. sizeof(struct qeth_ipacmd_sbp_hdr) +
  1730. sizeof(struct qeth_sbp_query_cmds_supp);
  1731. cmd->data.sbp.hdr.command_code =
  1732. IPA_SBP_QUERY_COMMANDS_SUPPORTED;
  1733. cmd->data.sbp.hdr.used_total = 1;
  1734. cmd->data.sbp.hdr.seq_no = 1;
  1735. if (qeth_send_ipa_cmd(card, iob, qeth_bridgeport_query_support_cb,
  1736. (void *)&cbctl) ||
  1737. qeth_bridgeport_makerc(card, &cbctl,
  1738. IPA_SBP_QUERY_COMMANDS_SUPPORTED)) {
  1739. /* non-zero makerc signifies failure, and produce messages */
  1740. card->options.sbp.role = QETH_SBP_ROLE_NONE;
  1741. return;
  1742. }
  1743. card->options.sbp.supported_funcs = cbctl.data.supported;
  1744. }
  1745. static int qeth_bridgeport_query_ports_cb(struct qeth_card *card,
  1746. struct qeth_reply *reply, unsigned long data)
  1747. {
  1748. struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data;
  1749. struct qeth_sbp_query_ports *qports = &cmd->data.sbp.data.query_ports;
  1750. struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param;
  1751. QETH_CARD_TEXT(card, 2, "brqprtcb");
  1752. cbctl->ipa_rc = cmd->hdr.return_code;
  1753. cbctl->cmd_rc = cmd->data.sbp.hdr.return_code;
  1754. if ((cbctl->ipa_rc != 0) || (cbctl->cmd_rc != 0))
  1755. return 0;
  1756. if (qports->entry_length != sizeof(struct qeth_sbp_port_entry)) {
  1757. cbctl->cmd_rc = 0xffff;
  1758. QETH_CARD_TEXT_(card, 2, "SBPs%04x", qports->entry_length);
  1759. return 0;
  1760. }
  1761. /* first entry contains the state of the local port */
  1762. if (qports->num_entries > 0) {
  1763. if (cbctl->data.qports.role)
  1764. *cbctl->data.qports.role = qports->entry[0].role;
  1765. if (cbctl->data.qports.state)
  1766. *cbctl->data.qports.state = qports->entry[0].state;
  1767. }
  1768. return 0;
  1769. }
  1770. /**
  1771. * qeth_bridgeport_query_ports() - query local bridgeport status.
  1772. * @card: qeth_card structure pointer.
  1773. * @role: Role of the port: 0-none, 1-primary, 2-secondary.
  1774. * @state: State of the port: 0-inactive, 1-standby, 2-active.
  1775. *
  1776. * Returns negative errno-compatible error indication or 0 on success.
  1777. *
  1778. * 'role' and 'state' are not updated in case of hardware operation failure.
  1779. */
  1780. int qeth_bridgeport_query_ports(struct qeth_card *card,
  1781. enum qeth_sbp_roles *role, enum qeth_sbp_states *state)
  1782. {
  1783. int rc = 0;
  1784. struct qeth_cmd_buffer *iob;
  1785. struct qeth_ipa_cmd *cmd;
  1786. struct _qeth_sbp_cbctl cbctl = {
  1787. .data = {
  1788. .qports = {
  1789. .role = role,
  1790. .state = state,
  1791. },
  1792. },
  1793. };
  1794. QETH_CARD_TEXT(card, 2, "brqports");
  1795. if (!(card->options.sbp.supported_funcs & IPA_SBP_QUERY_BRIDGE_PORTS))
  1796. return -EOPNOTSUPP;
  1797. iob = qeth_get_ipacmd_buffer(card, ipa_cmd_sbp(card), 0);
  1798. if (!iob)
  1799. return -ENOMEM;
  1800. cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
  1801. cmd->data.sbp.hdr.cmdlength =
  1802. sizeof(struct qeth_ipacmd_sbp_hdr);
  1803. cmd->data.sbp.hdr.command_code =
  1804. IPA_SBP_QUERY_BRIDGE_PORTS;
  1805. cmd->data.sbp.hdr.used_total = 1;
  1806. cmd->data.sbp.hdr.seq_no = 1;
  1807. rc = qeth_send_ipa_cmd(card, iob, qeth_bridgeport_query_ports_cb,
  1808. (void *)&cbctl);
  1809. if (rc < 0)
  1810. return rc;
  1811. return qeth_bridgeport_makerc(card, &cbctl, IPA_SBP_QUERY_BRIDGE_PORTS);
  1812. }
  1813. EXPORT_SYMBOL_GPL(qeth_bridgeport_query_ports);
  1814. static int qeth_bridgeport_set_cb(struct qeth_card *card,
  1815. struct qeth_reply *reply, unsigned long data)
  1816. {
  1817. struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *)data;
  1818. struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param;
  1819. QETH_CARD_TEXT(card, 2, "brsetrcb");
  1820. cbctl->ipa_rc = cmd->hdr.return_code;
  1821. cbctl->cmd_rc = cmd->data.sbp.hdr.return_code;
  1822. return 0;
  1823. }
  1824. /**
  1825. * qeth_bridgeport_setrole() - Assign primary role to the port.
  1826. * @card: qeth_card structure pointer.
  1827. * @role: Role to assign.
  1828. *
  1829. * Returns negative errno-compatible error indication or 0 on success.
  1830. */
  1831. int qeth_bridgeport_setrole(struct qeth_card *card, enum qeth_sbp_roles role)
  1832. {
  1833. int rc = 0;
  1834. int cmdlength;
  1835. struct qeth_cmd_buffer *iob;
  1836. struct qeth_ipa_cmd *cmd;
  1837. struct _qeth_sbp_cbctl cbctl;
  1838. enum qeth_ipa_sbp_cmd setcmd;
  1839. QETH_CARD_TEXT(card, 2, "brsetrol");
  1840. switch (role) {
  1841. case QETH_SBP_ROLE_NONE:
  1842. setcmd = IPA_SBP_RESET_BRIDGE_PORT_ROLE;
  1843. cmdlength = sizeof(struct qeth_ipacmd_sbp_hdr) +
  1844. sizeof(struct qeth_sbp_reset_role);
  1845. break;
  1846. case QETH_SBP_ROLE_PRIMARY:
  1847. setcmd = IPA_SBP_SET_PRIMARY_BRIDGE_PORT;
  1848. cmdlength = sizeof(struct qeth_ipacmd_sbp_hdr) +
  1849. sizeof(struct qeth_sbp_set_primary);
  1850. break;
  1851. case QETH_SBP_ROLE_SECONDARY:
  1852. setcmd = IPA_SBP_SET_SECONDARY_BRIDGE_PORT;
  1853. cmdlength = sizeof(struct qeth_ipacmd_sbp_hdr) +
  1854. sizeof(struct qeth_sbp_set_secondary);
  1855. break;
  1856. default:
  1857. return -EINVAL;
  1858. }
  1859. if (!(card->options.sbp.supported_funcs & setcmd))
  1860. return -EOPNOTSUPP;
  1861. iob = qeth_get_ipacmd_buffer(card, ipa_cmd_sbp(card), 0);
  1862. if (!iob)
  1863. return -ENOMEM;
  1864. cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
  1865. cmd->data.sbp.hdr.cmdlength = cmdlength;
  1866. cmd->data.sbp.hdr.command_code = setcmd;
  1867. cmd->data.sbp.hdr.used_total = 1;
  1868. cmd->data.sbp.hdr.seq_no = 1;
  1869. rc = qeth_send_ipa_cmd(card, iob, qeth_bridgeport_set_cb,
  1870. (void *)&cbctl);
  1871. if (rc < 0)
  1872. return rc;
  1873. return qeth_bridgeport_makerc(card, &cbctl, setcmd);
  1874. }
  1875. /**
  1876. * qeth_anset_makerc() - derive "traditional" error from hardware codes.
  1877. * @card: qeth_card structure pointer, for debug messages.
  1878. *
  1879. * Returns negative errno-compatible error indication or 0 on success.
  1880. */
  1881. static int qeth_anset_makerc(struct qeth_card *card, int pnso_rc, u16 response)
  1882. {
  1883. int rc;
  1884. if (pnso_rc == 0)
  1885. switch (response) {
  1886. case 0x0001:
  1887. rc = 0;
  1888. break;
  1889. case 0x0004:
  1890. case 0x0100:
  1891. case 0x0106:
  1892. rc = -EOPNOTSUPP;
  1893. dev_err(&card->gdev->dev,
  1894. "Setting address notification failed\n");
  1895. break;
  1896. case 0x0107:
  1897. rc = -EAGAIN;
  1898. break;
  1899. default:
  1900. rc = -EIO;
  1901. }
  1902. else
  1903. rc = -EIO;
  1904. if (rc) {
  1905. QETH_CARD_TEXT_(card, 2, "SBPp%04x", pnso_rc);
  1906. QETH_CARD_TEXT_(card, 2, "SBPr%04x", response);
  1907. }
  1908. return rc;
  1909. }
  1910. static void qeth_bridgeport_an_set_cb(void *priv,
  1911. enum qdio_brinfo_entry_type type, void *entry)
  1912. {
  1913. struct qeth_card *card = (struct qeth_card *)priv;
  1914. struct qdio_brinfo_entry_l2 *l2entry;
  1915. u8 code;
  1916. if (type != l2_addr_lnid) {
  1917. WARN_ON_ONCE(1);
  1918. return;
  1919. }
  1920. l2entry = (struct qdio_brinfo_entry_l2 *)entry;
  1921. code = IPA_ADDR_CHANGE_CODE_MACADDR;
  1922. if (l2entry->addr_lnid.lnid)
  1923. code |= IPA_ADDR_CHANGE_CODE_VLANID;
  1924. qeth_bridge_emit_host_event(card, anev_reg_unreg, code,
  1925. (struct net_if_token *)&l2entry->nit,
  1926. (struct mac_addr_lnid *)&l2entry->addr_lnid);
  1927. }
  1928. /**
  1929. * qeth_bridgeport_an_set() - Enable or disable bridgeport address notification
  1930. * @card: qeth_card structure pointer.
  1931. * @enable: 0 - disable, non-zero - enable notifications
  1932. *
  1933. * Returns negative errno-compatible error indication or 0 on success.
  1934. *
  1935. * On enable, emits a series of address notifications udev events for all
  1936. * currently registered hosts.
  1937. */
  1938. int qeth_bridgeport_an_set(struct qeth_card *card, int enable)
  1939. {
  1940. int rc;
  1941. u16 response;
  1942. struct ccw_device *ddev;
  1943. struct subchannel_id schid;
  1944. if (!card)
  1945. return -EINVAL;
  1946. if (!card->options.sbp.supported_funcs)
  1947. return -EOPNOTSUPP;
  1948. ddev = CARD_DDEV(card);
  1949. ccw_device_get_schid(ddev, &schid);
  1950. if (enable) {
  1951. qeth_bridge_emit_host_event(card, anev_reset, 0, NULL, NULL);
  1952. rc = qdio_pnso_brinfo(schid, 1, &response,
  1953. qeth_bridgeport_an_set_cb, card);
  1954. } else
  1955. rc = qdio_pnso_brinfo(schid, 0, &response, NULL, NULL);
  1956. return qeth_anset_makerc(card, rc, response);
  1957. }
  1958. EXPORT_SYMBOL_GPL(qeth_bridgeport_an_set);
  1959. module_init(qeth_l2_init);
  1960. module_exit(qeth_l2_exit);
  1961. MODULE_AUTHOR("Frank Blaschka <frank.blaschka@de.ibm.com>");
  1962. MODULE_DESCRIPTION("qeth layer 2 discipline");
  1963. MODULE_LICENSE("GPL");