xpnet.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * (C) Copyright 2020 Hewlett Packard Enterprise Development LP
  7. * Copyright (C) 1999-2009 Silicon Graphics, Inc. All rights reserved.
  8. */
  9. /*
  10. * Cross Partition Network Interface (XPNET) support
  11. *
  12. * XPNET provides a virtual network layered on top of the Cross
  13. * Partition communication layer.
  14. *
  15. * XPNET provides direct point-to-point and broadcast-like support
  16. * for an ethernet-like device. The ethernet broadcast medium is
  17. * replaced with a point-to-point message structure which passes
  18. * pointers to a DMA-capable block that a remote partition should
  19. * retrieve and pass to the upper level networking layer.
  20. *
  21. */
  22. #include <linux/slab.h>
  23. #include <linux/module.h>
  24. #include <linux/netdevice.h>
  25. #include <linux/etherdevice.h>
  26. #include "xp.h"
  27. /*
  28. * The message payload transferred by XPC.
  29. *
  30. * buf_pa is the physical address where the DMA should pull from.
  31. *
  32. * NOTE: for performance reasons, buf_pa should _ALWAYS_ begin on a
  33. * cacheline boundary. To accomplish this, we record the number of
  34. * bytes from the beginning of the first cacheline to the first useful
  35. * byte of the skb (leadin_ignore) and the number of bytes from the
  36. * last useful byte of the skb to the end of the last cacheline
  37. * (tailout_ignore).
  38. *
  39. * size is the number of bytes to transfer which includes the skb->len
  40. * (useful bytes of the senders skb) plus the leadin and tailout
  41. */
  42. struct xpnet_message {
  43. u16 version; /* Version for this message */
  44. u16 embedded_bytes; /* #of bytes embedded in XPC message */
  45. u32 magic; /* Special number indicating this is xpnet */
  46. unsigned long buf_pa; /* phys address of buffer to retrieve */
  47. u32 size; /* #of bytes in buffer */
  48. u8 leadin_ignore; /* #of bytes to ignore at the beginning */
  49. u8 tailout_ignore; /* #of bytes to ignore at the end */
  50. unsigned char data; /* body of small packets */
  51. };
  52. /*
  53. * Determine the size of our message, the cacheline aligned size,
  54. * and then the number of message will request from XPC.
  55. *
  56. * XPC expects each message to exist in an individual cacheline.
  57. */
  58. #define XPNET_MSG_SIZE XPC_MSG_PAYLOAD_MAX_SIZE
  59. #define XPNET_MSG_DATA_MAX \
  60. (XPNET_MSG_SIZE - offsetof(struct xpnet_message, data))
  61. #define XPNET_MSG_NENTRIES (PAGE_SIZE / XPC_MSG_MAX_SIZE)
  62. #define XPNET_MAX_KTHREADS (XPNET_MSG_NENTRIES + 1)
  63. #define XPNET_MAX_IDLE_KTHREADS (XPNET_MSG_NENTRIES + 1)
  64. /*
  65. * Version number of XPNET implementation. XPNET can always talk to versions
  66. * with same major #, and never talk to versions with a different version.
  67. */
  68. #define _XPNET_VERSION(_major, _minor) (((_major) << 4) | (_minor))
  69. #define XPNET_VERSION_MAJOR(_v) ((_v) >> 4)
  70. #define XPNET_VERSION_MINOR(_v) ((_v) & 0xf)
  71. #define XPNET_VERSION _XPNET_VERSION(1, 0) /* version 1.0 */
  72. #define XPNET_VERSION_EMBED _XPNET_VERSION(1, 1) /* version 1.1 */
  73. #define XPNET_MAGIC 0x88786984 /* "XNET" */
  74. #define XPNET_VALID_MSG(_m) \
  75. ((XPNET_VERSION_MAJOR(_m->version) == XPNET_VERSION_MAJOR(XPNET_VERSION)) \
  76. && (msg->magic == XPNET_MAGIC))
  77. #define XPNET_DEVICE_NAME "xp0"
  78. /*
  79. * When messages are queued with xpc_send_notify, a kmalloc'd buffer
  80. * of the following type is passed as a notification cookie. When the
  81. * notification function is called, we use the cookie to decide
  82. * whether all outstanding message sends have completed. The skb can
  83. * then be released.
  84. */
  85. struct xpnet_pending_msg {
  86. struct sk_buff *skb;
  87. atomic_t use_count;
  88. };
  89. static struct net_device *xpnet_device;
  90. /*
  91. * When we are notified of other partitions activating, we add them to
  92. * our bitmask of partitions to which we broadcast.
  93. */
  94. static unsigned long *xpnet_broadcast_partitions;
  95. /* protect above */
  96. static DEFINE_SPINLOCK(xpnet_broadcast_lock);
  97. /*
  98. * Since the Block Transfer Engine (BTE) is being used for the transfer
  99. * and it relies upon cache-line size transfers, we need to reserve at
  100. * least one cache-line for head and tail alignment. The BTE is
  101. * limited to 8MB transfers.
  102. *
  103. * Testing has shown that changing MTU to greater than 64KB has no effect
  104. * on TCP as the two sides negotiate a Max Segment Size that is limited
  105. * to 64K. Other protocols May use packets greater than this, but for
  106. * now, the default is 64KB.
  107. */
  108. #define XPNET_MAX_MTU (0x800000UL - L1_CACHE_BYTES)
  109. /* 68 comes from min TCP+IP+MAC header */
  110. #define XPNET_MIN_MTU 68
  111. /* 32KB has been determined to be the ideal */
  112. #define XPNET_DEF_MTU (0x8000UL)
  113. /*
  114. * The partid is encapsulated in the MAC address beginning in the following
  115. * octet and it consists of two octets.
  116. */
  117. #define XPNET_PARTID_OCTET 2
  118. /* Define the XPNET debug device structures to be used with dev_dbg() et al */
  119. static struct device_driver xpnet_dbg_name = {
  120. .name = "xpnet"
  121. };
  122. static struct device xpnet_dbg_subname = {
  123. .init_name = "", /* set to "" */
  124. .driver = &xpnet_dbg_name
  125. };
  126. static struct device *xpnet = &xpnet_dbg_subname;
  127. /*
  128. * Packet was recevied by XPC and forwarded to us.
  129. */
  130. static void
  131. xpnet_receive(short partid, int channel, struct xpnet_message *msg)
  132. {
  133. struct sk_buff *skb;
  134. void *dst;
  135. enum xp_retval ret;
  136. if (!XPNET_VALID_MSG(msg)) {
  137. /*
  138. * Packet with a different XPC version. Ignore.
  139. */
  140. xpc_received(partid, channel, (void *)msg);
  141. xpnet_device->stats.rx_errors++;
  142. return;
  143. }
  144. dev_dbg(xpnet, "received 0x%lx, %d, %d, %d\n", msg->buf_pa, msg->size,
  145. msg->leadin_ignore, msg->tailout_ignore);
  146. /* reserve an extra cache line */
  147. skb = dev_alloc_skb(msg->size + L1_CACHE_BYTES);
  148. if (!skb) {
  149. dev_err(xpnet, "failed on dev_alloc_skb(%d)\n",
  150. msg->size + L1_CACHE_BYTES);
  151. xpc_received(partid, channel, (void *)msg);
  152. xpnet_device->stats.rx_errors++;
  153. return;
  154. }
  155. /*
  156. * The allocated skb has some reserved space.
  157. * In order to use xp_remote_memcpy(), we need to get the
  158. * skb->data pointer moved forward.
  159. */
  160. skb_reserve(skb, (L1_CACHE_BYTES - ((u64)skb->data &
  161. (L1_CACHE_BYTES - 1)) +
  162. msg->leadin_ignore));
  163. /*
  164. * Update the tail pointer to indicate data actually
  165. * transferred.
  166. */
  167. skb_put(skb, (msg->size - msg->leadin_ignore - msg->tailout_ignore));
  168. /*
  169. * Move the data over from the other side.
  170. */
  171. if ((XPNET_VERSION_MINOR(msg->version) == 1) &&
  172. (msg->embedded_bytes != 0)) {
  173. dev_dbg(xpnet, "copying embedded message. memcpy(0x%p, 0x%p, "
  174. "%lu)\n", skb->data, &msg->data,
  175. (size_t)msg->embedded_bytes);
  176. skb_copy_to_linear_data(skb, &msg->data,
  177. (size_t)msg->embedded_bytes);
  178. } else {
  179. dst = (void *)((u64)skb->data & ~(L1_CACHE_BYTES - 1));
  180. dev_dbg(xpnet, "transferring buffer to the skb->data area;\n\t"
  181. "xp_remote_memcpy(0x%p, 0x%p, %hu)\n", dst,
  182. (void *)msg->buf_pa, msg->size);
  183. ret = xp_remote_memcpy(xp_pa(dst), msg->buf_pa, msg->size);
  184. if (ret != xpSuccess) {
  185. /*
  186. * !!! Need better way of cleaning skb. Currently skb
  187. * !!! appears in_use and we can't just call
  188. * !!! dev_kfree_skb.
  189. */
  190. dev_err(xpnet, "xp_remote_memcpy(0x%p, 0x%p, 0x%hx) "
  191. "returned error=0x%x\n", dst,
  192. (void *)msg->buf_pa, msg->size, ret);
  193. xpc_received(partid, channel, (void *)msg);
  194. xpnet_device->stats.rx_errors++;
  195. return;
  196. }
  197. }
  198. dev_dbg(xpnet, "<skb->head=0x%p skb->data=0x%p skb->tail=0x%p "
  199. "skb->end=0x%p skb->len=%d\n", (void *)skb->head,
  200. (void *)skb->data, skb_tail_pointer(skb), skb_end_pointer(skb),
  201. skb->len);
  202. skb->protocol = eth_type_trans(skb, xpnet_device);
  203. skb->ip_summed = CHECKSUM_UNNECESSARY;
  204. dev_dbg(xpnet, "passing skb to network layer\n"
  205. "\tskb->head=0x%p skb->data=0x%p skb->tail=0x%p "
  206. "skb->end=0x%p skb->len=%d\n",
  207. (void *)skb->head, (void *)skb->data, skb_tail_pointer(skb),
  208. skb_end_pointer(skb), skb->len);
  209. xpnet_device->stats.rx_packets++;
  210. xpnet_device->stats.rx_bytes += skb->len + ETH_HLEN;
  211. netif_rx_ni(skb);
  212. xpc_received(partid, channel, (void *)msg);
  213. }
  214. /*
  215. * This is the handler which XPC calls during any sort of change in
  216. * state or message reception on a connection.
  217. */
  218. static void
  219. xpnet_connection_activity(enum xp_retval reason, short partid, int channel,
  220. void *data, void *key)
  221. {
  222. DBUG_ON(partid < 0 || partid >= xp_max_npartitions);
  223. DBUG_ON(channel != XPC_NET_CHANNEL);
  224. switch (reason) {
  225. case xpMsgReceived: /* message received */
  226. DBUG_ON(data == NULL);
  227. xpnet_receive(partid, channel, (struct xpnet_message *)data);
  228. break;
  229. case xpConnected: /* connection completed to a partition */
  230. spin_lock_bh(&xpnet_broadcast_lock);
  231. __set_bit(partid, xpnet_broadcast_partitions);
  232. spin_unlock_bh(&xpnet_broadcast_lock);
  233. netif_carrier_on(xpnet_device);
  234. dev_dbg(xpnet, "%s connected to partition %d\n",
  235. xpnet_device->name, partid);
  236. break;
  237. default:
  238. spin_lock_bh(&xpnet_broadcast_lock);
  239. __clear_bit(partid, xpnet_broadcast_partitions);
  240. spin_unlock_bh(&xpnet_broadcast_lock);
  241. if (bitmap_empty((unsigned long *)xpnet_broadcast_partitions,
  242. xp_max_npartitions)) {
  243. netif_carrier_off(xpnet_device);
  244. }
  245. dev_dbg(xpnet, "%s disconnected from partition %d\n",
  246. xpnet_device->name, partid);
  247. break;
  248. }
  249. }
  250. static int
  251. xpnet_dev_open(struct net_device *dev)
  252. {
  253. enum xp_retval ret;
  254. dev_dbg(xpnet, "calling xpc_connect(%d, 0x%p, NULL, %ld, %ld, %ld, "
  255. "%ld)\n", XPC_NET_CHANNEL, xpnet_connection_activity,
  256. (unsigned long)XPNET_MSG_SIZE,
  257. (unsigned long)XPNET_MSG_NENTRIES,
  258. (unsigned long)XPNET_MAX_KTHREADS,
  259. (unsigned long)XPNET_MAX_IDLE_KTHREADS);
  260. ret = xpc_connect(XPC_NET_CHANNEL, xpnet_connection_activity, NULL,
  261. XPNET_MSG_SIZE, XPNET_MSG_NENTRIES,
  262. XPNET_MAX_KTHREADS, XPNET_MAX_IDLE_KTHREADS);
  263. if (ret != xpSuccess) {
  264. dev_err(xpnet, "ifconfig up of %s failed on XPC connect, "
  265. "ret=%d\n", dev->name, ret);
  266. return -ENOMEM;
  267. }
  268. dev_dbg(xpnet, "ifconfig up of %s; XPC connected\n", dev->name);
  269. return 0;
  270. }
  271. static int
  272. xpnet_dev_stop(struct net_device *dev)
  273. {
  274. xpc_disconnect(XPC_NET_CHANNEL);
  275. dev_dbg(xpnet, "ifconfig down of %s; XPC disconnected\n", dev->name);
  276. return 0;
  277. }
  278. /*
  279. * Notification that the other end has received the message and
  280. * DMA'd the skb information. At this point, they are done with
  281. * our side. When all recipients are done processing, we
  282. * release the skb and then release our pending message structure.
  283. */
  284. static void
  285. xpnet_send_completed(enum xp_retval reason, short partid, int channel,
  286. void *__qm)
  287. {
  288. struct xpnet_pending_msg *queued_msg = (struct xpnet_pending_msg *)__qm;
  289. DBUG_ON(queued_msg == NULL);
  290. dev_dbg(xpnet, "message to %d notified with reason %d\n",
  291. partid, reason);
  292. if (atomic_dec_return(&queued_msg->use_count) == 0) {
  293. dev_dbg(xpnet, "all acks for skb->head=-x%p\n",
  294. (void *)queued_msg->skb->head);
  295. dev_kfree_skb_any(queued_msg->skb);
  296. kfree(queued_msg);
  297. }
  298. }
  299. static void
  300. xpnet_send(struct sk_buff *skb, struct xpnet_pending_msg *queued_msg,
  301. u64 start_addr, u64 end_addr, u16 embedded_bytes, int dest_partid)
  302. {
  303. u8 msg_buffer[XPNET_MSG_SIZE];
  304. struct xpnet_message *msg = (struct xpnet_message *)&msg_buffer;
  305. u16 msg_size = sizeof(struct xpnet_message);
  306. enum xp_retval ret;
  307. msg->embedded_bytes = embedded_bytes;
  308. if (unlikely(embedded_bytes != 0)) {
  309. msg->version = XPNET_VERSION_EMBED;
  310. dev_dbg(xpnet, "calling memcpy(0x%p, 0x%p, 0x%lx)\n",
  311. &msg->data, skb->data, (size_t)embedded_bytes);
  312. skb_copy_from_linear_data(skb, &msg->data,
  313. (size_t)embedded_bytes);
  314. msg_size += embedded_bytes - 1;
  315. } else {
  316. msg->version = XPNET_VERSION;
  317. }
  318. msg->magic = XPNET_MAGIC;
  319. msg->size = end_addr - start_addr;
  320. msg->leadin_ignore = (u64)skb->data - start_addr;
  321. msg->tailout_ignore = end_addr - (u64)skb_tail_pointer(skb);
  322. msg->buf_pa = xp_pa((void *)start_addr);
  323. dev_dbg(xpnet, "sending XPC message to %d:%d\n"
  324. "msg->buf_pa=0x%lx, msg->size=%u, "
  325. "msg->leadin_ignore=%u, msg->tailout_ignore=%u\n",
  326. dest_partid, XPC_NET_CHANNEL, msg->buf_pa, msg->size,
  327. msg->leadin_ignore, msg->tailout_ignore);
  328. atomic_inc(&queued_msg->use_count);
  329. ret = xpc_send_notify(dest_partid, XPC_NET_CHANNEL, XPC_NOWAIT, msg,
  330. msg_size, xpnet_send_completed, queued_msg);
  331. if (unlikely(ret != xpSuccess))
  332. atomic_dec(&queued_msg->use_count);
  333. }
  334. /*
  335. * Network layer has formatted a packet (skb) and is ready to place it
  336. * "on the wire". Prepare and send an xpnet_message to all partitions
  337. * which have connected with us and are targets of this packet.
  338. *
  339. * MAC-NOTE: For the XPNET driver, the MAC address contains the
  340. * destination partid. If the destination partid octets are 0xffff,
  341. * this packet is to be broadcast to all connected partitions.
  342. */
  343. static netdev_tx_t
  344. xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
  345. {
  346. struct xpnet_pending_msg *queued_msg;
  347. u64 start_addr, end_addr;
  348. short dest_partid;
  349. u16 embedded_bytes = 0;
  350. dev_dbg(xpnet, ">skb->head=0x%p skb->data=0x%p skb->tail=0x%p "
  351. "skb->end=0x%p skb->len=%d\n", (void *)skb->head,
  352. (void *)skb->data, skb_tail_pointer(skb), skb_end_pointer(skb),
  353. skb->len);
  354. if (skb->data[0] == 0x33) {
  355. dev_kfree_skb(skb);
  356. return NETDEV_TX_OK; /* nothing needed to be done */
  357. }
  358. /*
  359. * The xpnet_pending_msg tracks how many outstanding
  360. * xpc_send_notifies are relying on this skb. When none
  361. * remain, release the skb.
  362. */
  363. queued_msg = kmalloc(sizeof(struct xpnet_pending_msg), GFP_ATOMIC);
  364. if (queued_msg == NULL) {
  365. dev_warn(xpnet, "failed to kmalloc %ld bytes; dropping "
  366. "packet\n", sizeof(struct xpnet_pending_msg));
  367. dev->stats.tx_errors++;
  368. dev_kfree_skb(skb);
  369. return NETDEV_TX_OK;
  370. }
  371. /* get the beginning of the first cacheline and end of last */
  372. start_addr = ((u64)skb->data & ~(L1_CACHE_BYTES - 1));
  373. end_addr = L1_CACHE_ALIGN((u64)skb_tail_pointer(skb));
  374. /* calculate how many bytes to embed in the XPC message */
  375. if (unlikely(skb->len <= XPNET_MSG_DATA_MAX)) {
  376. /* skb->data does fit so embed */
  377. embedded_bytes = skb->len;
  378. }
  379. /*
  380. * Since the send occurs asynchronously, we set the count to one
  381. * and begin sending. Any sends that happen to complete before
  382. * we are done sending will not free the skb. We will be left
  383. * with that task during exit. This also handles the case of
  384. * a packet destined for a partition which is no longer up.
  385. */
  386. atomic_set(&queued_msg->use_count, 1);
  387. queued_msg->skb = skb;
  388. if (skb->data[0] == 0xff) {
  389. /* we are being asked to broadcast to all partitions */
  390. for_each_set_bit(dest_partid, xpnet_broadcast_partitions,
  391. xp_max_npartitions) {
  392. xpnet_send(skb, queued_msg, start_addr, end_addr,
  393. embedded_bytes, dest_partid);
  394. }
  395. } else {
  396. dest_partid = (short)skb->data[XPNET_PARTID_OCTET + 1];
  397. dest_partid |= (short)skb->data[XPNET_PARTID_OCTET + 0] << 8;
  398. if (dest_partid >= 0 &&
  399. dest_partid < xp_max_npartitions &&
  400. test_bit(dest_partid, xpnet_broadcast_partitions) != 0) {
  401. xpnet_send(skb, queued_msg, start_addr, end_addr,
  402. embedded_bytes, dest_partid);
  403. }
  404. }
  405. dev->stats.tx_packets++;
  406. dev->stats.tx_bytes += skb->len;
  407. if (atomic_dec_return(&queued_msg->use_count) == 0) {
  408. dev_kfree_skb(skb);
  409. kfree(queued_msg);
  410. }
  411. return NETDEV_TX_OK;
  412. }
  413. /*
  414. * Deal with transmit timeouts coming from the network layer.
  415. */
  416. static void
  417. xpnet_dev_tx_timeout(struct net_device *dev, unsigned int txqueue)
  418. {
  419. dev->stats.tx_errors++;
  420. }
  421. static const struct net_device_ops xpnet_netdev_ops = {
  422. .ndo_open = xpnet_dev_open,
  423. .ndo_stop = xpnet_dev_stop,
  424. .ndo_start_xmit = xpnet_dev_hard_start_xmit,
  425. .ndo_tx_timeout = xpnet_dev_tx_timeout,
  426. .ndo_set_mac_address = eth_mac_addr,
  427. .ndo_validate_addr = eth_validate_addr,
  428. };
  429. static int __init
  430. xpnet_init(void)
  431. {
  432. int result;
  433. if (!is_uv_system())
  434. return -ENODEV;
  435. dev_info(xpnet, "registering network device %s\n", XPNET_DEVICE_NAME);
  436. xpnet_broadcast_partitions = kcalloc(BITS_TO_LONGS(xp_max_npartitions),
  437. sizeof(long),
  438. GFP_KERNEL);
  439. if (xpnet_broadcast_partitions == NULL)
  440. return -ENOMEM;
  441. /*
  442. * use ether_setup() to init the majority of our device
  443. * structure and then override the necessary pieces.
  444. */
  445. xpnet_device = alloc_netdev(0, XPNET_DEVICE_NAME, NET_NAME_UNKNOWN,
  446. ether_setup);
  447. if (xpnet_device == NULL) {
  448. kfree(xpnet_broadcast_partitions);
  449. return -ENOMEM;
  450. }
  451. netif_carrier_off(xpnet_device);
  452. xpnet_device->netdev_ops = &xpnet_netdev_ops;
  453. xpnet_device->mtu = XPNET_DEF_MTU;
  454. xpnet_device->min_mtu = XPNET_MIN_MTU;
  455. xpnet_device->max_mtu = XPNET_MAX_MTU;
  456. /*
  457. * Multicast assumes the LSB of the first octet is set for multicast
  458. * MAC addresses. We chose the first octet of the MAC to be unlikely
  459. * to collide with any vendor's officially issued MAC.
  460. */
  461. xpnet_device->dev_addr[0] = 0x02; /* locally administered, no OUI */
  462. xpnet_device->dev_addr[XPNET_PARTID_OCTET + 1] = xp_partition_id;
  463. xpnet_device->dev_addr[XPNET_PARTID_OCTET + 0] = (xp_partition_id >> 8);
  464. /*
  465. * ether_setup() sets this to a multicast device. We are
  466. * really not supporting multicast at this time.
  467. */
  468. xpnet_device->flags &= ~IFF_MULTICAST;
  469. /*
  470. * No need to checksum as it is a DMA transfer. The BTE will
  471. * report an error if the data is not retrievable and the
  472. * packet will be dropped.
  473. */
  474. xpnet_device->features = NETIF_F_HW_CSUM;
  475. result = register_netdev(xpnet_device);
  476. if (result != 0) {
  477. free_netdev(xpnet_device);
  478. kfree(xpnet_broadcast_partitions);
  479. }
  480. return result;
  481. }
  482. module_init(xpnet_init);
  483. static void __exit
  484. xpnet_exit(void)
  485. {
  486. dev_info(xpnet, "unregistering network device %s\n",
  487. xpnet_device[0].name);
  488. unregister_netdev(xpnet_device);
  489. free_netdev(xpnet_device);
  490. kfree(xpnet_broadcast_partitions);
  491. }
  492. module_exit(xpnet_exit);
  493. MODULE_AUTHOR("Silicon Graphics, Inc.");
  494. MODULE_DESCRIPTION("Cross Partition Network adapter (XPNET)");
  495. MODULE_LICENSE("GPL");