xpnet.c 18 KB

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