+ outputf("3c90x: Status (%hhX)", status);
+ /** check error codes **/
+ if (status & 0x02)
+ {
+ outputf("3c90x: Tx Reclaim Error (%hhX)", status);
+ a3c90x_reset();
+ } else if (status & 0x04) {
+ outputf("3c90x: Tx Status Overflow (%hhX)", status);
+ for (i=0; i<32; i++)
+ _outb(0x00, INF_3C90X.IOAddr + regTxStatus_b);
+ /** must re-enable after max collisions before re-issuing tx **/
+ _issue_command(INF_3C90X.IOAddr, cmdTxEnable, 0);
+ } else if (status & 0x08) {
+ outputf("3c90x: Tx Max Collisions (%hhX)", status);
+ /** must re-enable after max collisions before re-issuing tx **/
+ _issue_command(INF_3C90X.IOAddr, cmdTxEnable, 0);
+ } else if (status & 0x10) {
+ outputf("3c90x: Tx Underrun (%hhX)", status);
+ a3c90x_reset();
+ } else if (status & 0x20) {
+ outputf("3c90x: Tx Jabber (%hhX)", status);
+ a3c90x_reset();
+ } else if ((status & 0x80) != 0x80) {
+ outputf("3c90x: Internal Error - Incomplete Transmission (%hhX)", status);
+ a3c90x_reset();
+ }
+#endif
+}
+
+/* _setup_recv allocates and sets a pbuf from lwIP as the active receive
+ * packet chain for the 3c90x. The 3c90x must not be trying to receive
+ * when _setup_recv is being called.
+ */
+static void _setup_recv(struct nic *nic)
+{
+ struct pbuf *p, *q;
+ int i;
+
+ rxdesc.status = 0; /* Clear it out in the very beginning. */
+
+ p = pbuf_alloc(PBUF_RAW, 1536 /* XXX magic Max len */, PBUF_POOL);
+ if (!p)
+ {
+ outputf("3c90x: out of memory for packet?");
+ currecv = p;
+ return;
+ }
+
+ rxdesc.next = 0;
+ rxdesc.status = 0;
+ for (i = 0, q = p; q; q = q->next, i++)
+ {
+ rxdesc.segments[i].addr = v2p(q->payload);
+ rxdesc.segments[i].len = q->len | (q->next ? 0 : (1 << 31));
+ }
+
+ outl(INF_3C90X.IOAddr + regUpListPtr_l, v2p(&rxdesc));
+
+ currecv = p;
+}