1 typedef uint32_t __u32;
2 typedef uint16_t __u16;
5 static int verbose_messages=0;
6 static int print_info=0;
7 static int fatal_condition=0;
10 #define tprintf(fmt, a...) \
12 if ( verbose_messages ) { \
13 printf("%s:%d: " fmt "\n", __func__, __LINE__, ##a); \
18 #define eprintf(fmt, a...) \
19 printf("%s:%d: " fmt "\n", __func__, __LINE__, ##a)
21 static void cpu_to_be_buf(void *buf, int size)
23 int dw_sz = size >> 2, i;
25 for (i = 0; i < dw_sz; ++i) {
26 ((__u32 *) buf)[i] = cpu_to_be32(((__u32 *) buf)[i]);
30 static void be_to_cpu_buf(void *buf, int size)
32 int dw_sz = size >> 2, i;
35 for (i = 0; i < dw_sz; ++i) {
36 p[i] = be32_to_cpu(p[i]);
40 #include "cmdif_mt23108.c"
41 #include "cmdif_comm.c"
42 #include "ib_mt23108.c"
44 #include "ib_driver.c"
47 static int probe_imp(struct pci_device *pci, struct nic *nic)
51 if (0 && nic) { /* just to supress warning */
68 static int disable_imp(void)
72 rc = ipoib_close(fw_fatal);
77 static int transmit_imp(const char *dest, /* Destination */
78 unsigned int type, /* Type */
79 const char *packet, /* Packet */
84 if (fatal_condition) {
85 /* since the transmit function does not return a value
86 we return success but do nothing to suppress error messages */
90 rc = ipoib_send_packet(dest, type, packet, size);
92 printf("*** ERROR IN SEND FLOW ***\n");
93 printf("restarting Etherboot\n");
95 longjmp(restart_etherboot, -1);
96 /* we should not be here ... */
103 static void hd(void *where, int n)
108 printf("%X ", where);
109 for (i = 0; i < ((n > 16) ? 16 : n); i++)
110 printf(" %hhX", ((char *)where)[i]);
117 static int poll_imp(struct nic *nic, int retrieve, unsigned int *size_p)
119 static char packet[2048];
120 static char *last_packet_p = NULL;
121 static unsigned long last_packet_size;
123 const int eth_header_len = 14;
124 unsigned int packet_len;
129 if (0 && nic) { /* just to supress warning */
133 if (fatal_condition) {
138 if (poll_error_buf()) {
141 printf("\n *** DEVICE FATAL ERROR ***\n");
144 else if (drain_eq()) {
146 printf("\n *** FATAL ERROR ***\n");
152 /* we actually want to read the packet */
155 /* there is already a packet that was previously read */
156 memcpy(nic->packet, last_packet_p, last_packet_size);
157 *size_p = last_packet_size;
158 last_packet_p = NULL;
161 packet_p = nic->packet;
163 /* we don't want to read the packet,
164 just know if there is one. so we
165 read the packet to a local buffer and
166 we will return that buffer when the ip layer wants
169 /* there is already a packet that
171 eprintf("overflow receive packets");
177 rc = ipoib_read_packet(&prot, packet_p + eth_header_len, &packet_len,
180 printf("*** FATAL IN RECEIVE FLOW ****\n");
184 if (packet_len == 0) {
191 for (i = 0; i < 6; ++i) {
195 packet_p[0] = MLX_ETH_BYTE0;
196 packet_p[1] = MLX_ETH_BYTE1;
197 packet_p[2] = MLX_ETH_BYTE2;
203 memset(packet_p + 6, 0, 6);
205 ptr = (__u16 *) (packet_p + 12);
209 last_packet_p = packet;
210 last_packet_size = packet_len + eth_header_len;
214 *size_p = packet_len + eth_header_len;
215 tprintf("packet size=%d, prot=%x\n", *size_p, prot);
223 printf("restarting Etherboot\n");
225 longjmp(restart_etherboot, -1);
226 /* we should not be here ... */