xpnet.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  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 = netdev_priv(xpnet_device);
  137. if (!XPNET_VALID_MSG(msg)) {
  138. /*
  139. * Packet with a different XPC version. Ignore.
  140. */
  141. xpc_received(partid, channel, (void *)msg);
  142. priv->stats.rx_errors++;
  143. return;
  144. }
  145. dev_dbg(xpnet, "received 0x%lx, %d, %d, %d\n", msg->buf_pa, msg->size,
  146. msg->leadin_ignore, msg->tailout_ignore);
  147. /* reserve an extra cache line */
  148. skb = dev_alloc_skb(msg->size + L1_CACHE_BYTES);
  149. if (!skb) {
  150. dev_err(xpnet, "failed on dev_alloc_skb(%d)\n",
  151. msg->size + L1_CACHE_BYTES);
  152. xpc_received(partid, channel, (void *)msg);
  153. priv->stats.rx_errors++;
  154. return;
  155. }
  156. /*
  157. * The allocated skb has some reserved space.
  158. * In order to use xp_remote_memcpy(), we need to get the
  159. * skb->data pointer moved forward.
  160. */
  161. skb_reserve(skb, (L1_CACHE_BYTES - ((u64)skb->data &
  162. (L1_CACHE_BYTES - 1)) +
  163. msg->leadin_ignore));
  164. /*
  165. * Update the tail pointer to indicate data actually
  166. * transferred.
  167. */
  168. skb_put(skb, (msg->size - msg->leadin_ignore - msg->tailout_ignore));
  169. /*
  170. * Move the data over from the other side.
  171. */
  172. if ((XPNET_VERSION_MINOR(msg->version) == 1) &&
  173. (msg->embedded_bytes != 0)) {
  174. dev_dbg(xpnet, "copying embedded message. memcpy(0x%p, 0x%p, "
  175. "%lu)\n", skb->data, &msg->data,
  176. (size_t)msg->embedded_bytes);
  177. skb_copy_to_linear_data(skb, &msg->data,
  178. (size_t)msg->embedded_bytes);
  179. } else {
  180. dst = (void *)((u64)skb->data & ~(L1_CACHE_BYTES - 1));
  181. dev_dbg(xpnet, "transferring buffer to the skb->data area;\n\t"
  182. "xp_remote_memcpy(0x%p, 0x%p, %hu)\n", dst,
  183. (void *)msg->buf_pa, msg->size);
  184. ret = xp_remote_memcpy(xp_pa(dst), msg->buf_pa, msg->size);
  185. if (ret != xpSuccess) {
  186. /*
  187. * !!! Need better way of cleaning skb. Currently skb
  188. * !!! appears in_use and we can't just call
  189. * !!! dev_kfree_skb.
  190. */
  191. dev_err(xpnet, "xp_remote_memcpy(0x%p, 0x%p, 0x%hx) "
  192. "returned error=0x%x\n", dst,
  193. (void *)msg->buf_pa, msg->size, ret);
  194. xpc_received(partid, channel, (void *)msg);
  195. priv->stats.rx_errors++;
  196. return;
  197. }
  198. }
  199. dev_dbg(xpnet, "<skb->head=0x%p skb->data=0x%p skb->tail=0x%p "
  200. "skb->end=0x%p skb->len=%d\n", (void *)skb->head,
  201. (void *)skb->data, skb_tail_pointer(skb), skb_end_pointer(skb),
  202. skb->len);
  203. skb->protocol = eth_type_trans(skb, xpnet_device);
  204. skb->ip_summed = CHECKSUM_UNNECESSARY;
  205. dev_dbg(xpnet, "passing skb to network layer\n"
  206. KERN_DEBUG "\tskb->head=0x%p skb->data=0x%p skb->tail=0x%p "
  207. "skb->end=0x%p skb->len=%d\n",
  208. (void *)skb->head, (void *)skb->data, skb_tail_pointer(skb),
  209. skb_end_pointer(skb), skb->len);
  210. xpnet_device->last_rx = jiffies;
  211. priv->stats.rx_packets++;
  212. priv->stats.rx_bytes += skb->len + ETH_HLEN;
  213. netif_rx_ni(skb);
  214. xpc_received(partid, channel, (void *)msg);
  215. }
  216. /*
  217. * This is the handler which XPC calls during any sort of change in
  218. * state or message reception on a connection.
  219. */
  220. static void
  221. xpnet_connection_activity(enum xp_retval reason, short partid, int channel,
  222. void *data, void *key)
  223. {
  224. DBUG_ON(partid < 0 || partid >= xp_max_npartitions);
  225. DBUG_ON(channel != XPC_NET_CHANNEL);
  226. switch (reason) {
  227. case xpMsgReceived: /* message received */
  228. DBUG_ON(data == NULL);
  229. xpnet_receive(partid, channel, (struct xpnet_message *)data);
  230. break;
  231. case xpConnected: /* connection completed to a partition */
  232. spin_lock_bh(&xpnet_broadcast_lock);
  233. __set_bit(partid, xpnet_broadcast_partitions);
  234. spin_unlock_bh(&xpnet_broadcast_lock);
  235. netif_carrier_on(xpnet_device);
  236. dev_dbg(xpnet, "%s connected to partition %d\n",
  237. xpnet_device->name, partid);
  238. break;
  239. default:
  240. spin_lock_bh(&xpnet_broadcast_lock);
  241. __clear_bit(partid, xpnet_broadcast_partitions);
  242. spin_unlock_bh(&xpnet_broadcast_lock);
  243. if (bitmap_empty((unsigned long *)xpnet_broadcast_partitions,
  244. xp_max_npartitions)) {
  245. netif_carrier_off(xpnet_device);
  246. }
  247. dev_dbg(xpnet, "%s disconnected from partition %d\n",
  248. xpnet_device->name, partid);
  249. break;
  250. }
  251. }
  252. static int
  253. xpnet_dev_open(struct net_device *dev)
  254. {
  255. enum xp_retval ret;
  256. dev_dbg(xpnet, "calling xpc_connect(%d, 0x%p, NULL, %ld, %ld, %ld, "
  257. "%ld)\n", XPC_NET_CHANNEL, xpnet_connection_activity,
  258. (unsigned long)XPNET_MSG_SIZE,
  259. (unsigned long)XPNET_MSG_NENTRIES,
  260. (unsigned long)XPNET_MAX_KTHREADS,
  261. (unsigned long)XPNET_MAX_IDLE_KTHREADS);
  262. ret = xpc_connect(XPC_NET_CHANNEL, xpnet_connection_activity, NULL,
  263. XPNET_MSG_SIZE, XPNET_MSG_NENTRIES,
  264. XPNET_MAX_KTHREADS, XPNET_MAX_IDLE_KTHREADS);
  265. if (ret != xpSuccess) {
  266. dev_err(xpnet, "ifconfig up of %s failed on XPC connect, "
  267. "ret=%d\n", dev->name, ret);
  268. return -ENOMEM;
  269. }
  270. dev_dbg(xpnet, "ifconfig up of %s; XPC connected\n", dev->name);
  271. return 0;
  272. }
  273. static int
  274. xpnet_dev_stop(struct net_device *dev)
  275. {
  276. xpc_disconnect(XPC_NET_CHANNEL);
  277. dev_dbg(xpnet, "ifconfig down of %s; XPC disconnected\n", dev->name);
  278. return 0;
  279. }
  280. static int
  281. xpnet_dev_change_mtu(struct net_device *dev, int new_mtu)
  282. {
  283. /* 68 comes from min TCP+IP+MAC header */
  284. if ((new_mtu < 68) || (new_mtu > XPNET_MAX_MTU)) {
  285. dev_err(xpnet, "ifconfig %s mtu %d failed; value must be "
  286. "between 68 and %ld\n", dev->name, new_mtu,
  287. XPNET_MAX_MTU);
  288. return -EINVAL;
  289. }
  290. dev->mtu = new_mtu;
  291. dev_dbg(xpnet, "ifconfig %s mtu set to %d\n", dev->name, new_mtu);
  292. return 0;
  293. }
  294. /*
  295. * Required for the net_device structure.
  296. */
  297. static int
  298. xpnet_dev_set_config(struct net_device *dev, struct ifmap *new_map)
  299. {
  300. return 0;
  301. }
  302. /*
  303. * Return statistics to the caller.
  304. */
  305. static struct net_device_stats *
  306. xpnet_dev_get_stats(struct net_device *dev)
  307. {
  308. struct xpnet_dev_private *priv = netdev_priv(dev);
  309. return &priv->stats;
  310. }
  311. /*
  312. * Notification that the other end has received the message and
  313. * DMA'd the skb information. At this point, they are done with
  314. * our side. When all recipients are done processing, we
  315. * release the skb and then release our pending message structure.
  316. */
  317. static void
  318. xpnet_send_completed(enum xp_retval reason, short partid, int channel,
  319. void *__qm)
  320. {
  321. struct xpnet_pending_msg *queued_msg = (struct xpnet_pending_msg *)__qm;
  322. DBUG_ON(queued_msg == NULL);
  323. dev_dbg(xpnet, "message to %d notified with reason %d\n",
  324. partid, reason);
  325. if (atomic_dec_return(&queued_msg->use_count) == 0) {
  326. dev_dbg(xpnet, "all acks for skb->head=-x%p\n",
  327. (void *)queued_msg->skb->head);
  328. dev_kfree_skb_any(queued_msg->skb);
  329. kfree(queued_msg);
  330. }
  331. }
  332. static void
  333. xpnet_send(struct sk_buff *skb, struct xpnet_pending_msg *queued_msg,
  334. u64 start_addr, u64 end_addr, u16 embedded_bytes, int dest_partid)
  335. {
  336. u8 msg_buffer[XPNET_MSG_SIZE];
  337. struct xpnet_message *msg = (struct xpnet_message *)&msg_buffer;
  338. u16 msg_size = sizeof(struct xpnet_message);
  339. enum xp_retval ret;
  340. msg->embedded_bytes = embedded_bytes;
  341. if (unlikely(embedded_bytes != 0)) {
  342. msg->version = XPNET_VERSION_EMBED;
  343. dev_dbg(xpnet, "calling memcpy(0x%p, 0x%p, 0x%lx)\n",
  344. &msg->data, skb->data, (size_t)embedded_bytes);
  345. skb_copy_from_linear_data(skb, &msg->data,
  346. (size_t)embedded_bytes);
  347. msg_size += embedded_bytes - 1;
  348. } else {
  349. msg->version = XPNET_VERSION;
  350. }
  351. msg->magic = XPNET_MAGIC;
  352. msg->size = end_addr - start_addr;
  353. msg->leadin_ignore = (u64)skb->data - start_addr;
  354. msg->tailout_ignore = end_addr - (u64)skb_tail_pointer(skb);
  355. msg->buf_pa = xp_pa((void *)start_addr);
  356. dev_dbg(xpnet, "sending XPC message to %d:%d\n"
  357. KERN_DEBUG "msg->buf_pa=0x%lx, msg->size=%u, "
  358. "msg->leadin_ignore=%u, msg->tailout_ignore=%u\n",
  359. dest_partid, XPC_NET_CHANNEL, msg->buf_pa, msg->size,
  360. msg->leadin_ignore, msg->tailout_ignore);
  361. atomic_inc(&queued_msg->use_count);
  362. ret = xpc_send_notify(dest_partid, XPC_NET_CHANNEL, XPC_NOWAIT, msg,
  363. msg_size, xpnet_send_completed, queued_msg);
  364. if (unlikely(ret != xpSuccess))
  365. atomic_dec(&queued_msg->use_count);
  366. }
  367. /*
  368. * Network layer has formatted a packet (skb) and is ready to place it
  369. * "on the wire". Prepare and send an xpnet_message to all partitions
  370. * which have connected with us and are targets of this packet.
  371. *
  372. * MAC-NOTE: For the XPNET driver, the MAC address contains the
  373. * destination partid. If the destination partid octets are 0xffff,
  374. * this packet is to be broadcast to all connected partitions.
  375. */
  376. static int
  377. xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
  378. {
  379. struct xpnet_pending_msg *queued_msg;
  380. u64 start_addr, end_addr;
  381. short dest_partid;
  382. struct xpnet_dev_private *priv = netdev_priv(dev);
  383. u16 embedded_bytes = 0;
  384. dev_dbg(xpnet, ">skb->head=0x%p skb->data=0x%p skb->tail=0x%p "
  385. "skb->end=0x%p skb->len=%d\n", (void *)skb->head,
  386. (void *)skb->data, skb_tail_pointer(skb), skb_end_pointer(skb),
  387. skb->len);
  388. if (skb->data[0] == 0x33) {
  389. dev_kfree_skb(skb);
  390. return 0; /* nothing needed to be done */
  391. }
  392. /*
  393. * The xpnet_pending_msg tracks how many outstanding
  394. * xpc_send_notifies are relying on this skb. When none
  395. * remain, release the skb.
  396. */
  397. queued_msg = kmalloc(sizeof(struct xpnet_pending_msg), GFP_ATOMIC);
  398. if (queued_msg == NULL) {
  399. dev_warn(xpnet, "failed to kmalloc %ld bytes; dropping "
  400. "packet\n", sizeof(struct xpnet_pending_msg));
  401. priv->stats.tx_errors++;
  402. return -ENOMEM;
  403. }
  404. /* get the beginning of the first cacheline and end of last */
  405. start_addr = ((u64)skb->data & ~(L1_CACHE_BYTES - 1));
  406. end_addr = L1_CACHE_ALIGN((u64)skb_tail_pointer(skb));
  407. /* calculate how many bytes to embed in the XPC message */
  408. if (unlikely(skb->len <= XPNET_MSG_DATA_MAX)) {
  409. /* skb->data does fit so embed */
  410. embedded_bytes = skb->len;
  411. }
  412. /*
  413. * Since the send occurs asynchronously, we set the count to one
  414. * and begin sending. Any sends that happen to complete before
  415. * we are done sending will not free the skb. We will be left
  416. * with that task during exit. This also handles the case of
  417. * a packet destined for a partition which is no longer up.
  418. */
  419. atomic_set(&queued_msg->use_count, 1);
  420. queued_msg->skb = skb;
  421. if (skb->data[0] == 0xff) {
  422. /* we are being asked to broadcast to all partitions */
  423. for_each_bit(dest_partid, xpnet_broadcast_partitions,
  424. xp_max_npartitions) {
  425. xpnet_send(skb, queued_msg, start_addr, end_addr,
  426. embedded_bytes, dest_partid);
  427. }
  428. } else {
  429. dest_partid = (short)skb->data[XPNET_PARTID_OCTET + 1];
  430. dest_partid |= (short)skb->data[XPNET_PARTID_OCTET + 0] << 8;
  431. if (dest_partid >= 0 &&
  432. dest_partid < xp_max_npartitions &&
  433. test_bit(dest_partid, xpnet_broadcast_partitions) != 0) {
  434. xpnet_send(skb, queued_msg, start_addr, end_addr,
  435. embedded_bytes, dest_partid);
  436. }
  437. }
  438. if (atomic_dec_return(&queued_msg->use_count) == 0) {
  439. dev_kfree_skb(skb);
  440. kfree(queued_msg);
  441. }
  442. priv->stats.tx_packets++;
  443. priv->stats.tx_bytes += skb->len;
  444. return 0;
  445. }
  446. /*
  447. * Deal with transmit timeouts coming from the network layer.
  448. */
  449. static void
  450. xpnet_dev_tx_timeout(struct net_device *dev)
  451. {
  452. struct xpnet_dev_private *priv = netdev_priv(dev);
  453. priv->stats.tx_errors++;
  454. return;
  455. }
  456. static int __init
  457. xpnet_init(void)
  458. {
  459. int result;
  460. if (!is_shub() && !is_uv())
  461. return -ENODEV;
  462. dev_info(xpnet, "registering network device %s\n", XPNET_DEVICE_NAME);
  463. xpnet_broadcast_partitions = kzalloc(BITS_TO_LONGS(xp_max_npartitions) *
  464. sizeof(long), GFP_KERNEL);
  465. if (xpnet_broadcast_partitions == NULL)
  466. return -ENOMEM;
  467. /*
  468. * use ether_setup() to init the majority of our device
  469. * structure and then override the necessary pieces.
  470. */
  471. xpnet_device = alloc_netdev(sizeof(struct xpnet_dev_private),
  472. XPNET_DEVICE_NAME, ether_setup);
  473. if (xpnet_device == NULL) {
  474. kfree(xpnet_broadcast_partitions);
  475. return -ENOMEM;
  476. }
  477. netif_carrier_off(xpnet_device);
  478. xpnet_device->mtu = XPNET_DEF_MTU;
  479. xpnet_device->change_mtu = xpnet_dev_change_mtu;
  480. xpnet_device->open = xpnet_dev_open;
  481. xpnet_device->get_stats = xpnet_dev_get_stats;
  482. xpnet_device->stop = xpnet_dev_stop;
  483. xpnet_device->hard_start_xmit = xpnet_dev_hard_start_xmit;
  484. xpnet_device->tx_timeout = xpnet_dev_tx_timeout;
  485. xpnet_device->set_config = xpnet_dev_set_config;
  486. /*
  487. * Multicast assumes the LSB of the first octet is set for multicast
  488. * MAC addresses. We chose the first octet of the MAC to be unlikely
  489. * to collide with any vendor's officially issued MAC.
  490. */
  491. xpnet_device->dev_addr[0] = 0x02; /* locally administered, no OUI */
  492. xpnet_device->dev_addr[XPNET_PARTID_OCTET + 1] = xp_partition_id;
  493. xpnet_device->dev_addr[XPNET_PARTID_OCTET + 0] = (xp_partition_id >> 8);
  494. /*
  495. * ether_setup() sets this to a multicast device. We are
  496. * really not supporting multicast at this time.
  497. */
  498. xpnet_device->flags &= ~IFF_MULTICAST;
  499. /*
  500. * No need to checksum as it is a DMA transfer. The BTE will
  501. * report an error if the data is not retrievable and the
  502. * packet will be dropped.
  503. */
  504. xpnet_device->features = NETIF_F_NO_CSUM;
  505. result = register_netdev(xpnet_device);
  506. if (result != 0) {
  507. free_netdev(xpnet_device);
  508. kfree(xpnet_broadcast_partitions);
  509. }
  510. return result;
  511. }
  512. module_init(xpnet_init);
  513. static void __exit
  514. xpnet_exit(void)
  515. {
  516. dev_info(xpnet, "unregistering network device %s\n",
  517. xpnet_device[0].name);
  518. unregister_netdev(xpnet_device);
  519. free_netdev(xpnet_device);
  520. kfree(xpnet_broadcast_partitions);
  521. }
  522. module_exit(xpnet_exit);
  523. MODULE_AUTHOR("Silicon Graphics, Inc.");
  524. MODULE_DESCRIPTION("Cross Partition Network adapter (XPNET)");
  525. MODULE_LICENSE("GPL");