xpnet.c 18 KB

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