Lines 44-52
Link Here
|
44 |
#include <sys/mutex.h> |
44 |
#include <sys/mutex.h> |
45 |
#include <sys/mbuf.h> |
45 |
#include <sys/mbuf.h> |
46 |
#include <sys/sysctl.h> |
46 |
#include <sys/sysctl.h> |
|
|
47 |
#include <sys/endian.h> |
47 |
|
48 |
|
48 |
#include <dev/aoe/aoe.h> |
49 |
#include <dev/aoe/aoe.h> |
49 |
|
50 |
|
|
|
51 |
#include <sys/param.h> |
52 |
#include <sys/systm.h> |
53 |
#include <sys/mbuf.h> |
54 |
#include <sys/sysctl.h> |
55 |
#include <sys/kernel.h> |
56 |
#include <sys/socket.h> |
57 |
|
58 |
#include <net/bpf.h> |
59 |
#include <net/ethernet.h> |
60 |
#include <net/if.h> |
61 |
#include <net/if_var.h> |
62 |
#include <net/if_types.h> |
63 |
#include <net/if_arp.h> |
64 |
#include <net/netisr.h> |
65 |
|
66 |
|
67 |
#include <net/if.h> |
68 |
#include <net/if_var.h> |
69 |
#include <net/if_types.h> |
70 |
#include <net/if_arp.h> |
71 |
|
72 |
|
50 |
#define TIMERTICK (hz / 10) |
73 |
#define TIMERTICK (hz / 10) |
51 |
#define MINTIMER (2 * TIMERTICK) |
74 |
#define MINTIMER (2 * TIMERTICK) |
52 |
#define MAXTIMER (hz << 1) |
75 |
#define MAXTIMER (hz << 1) |
Lines 147-156
Link Here
|
147 |
*/ |
170 |
*/ |
148 |
bcnt = bp->bio_resid; |
171 |
bcnt = bp->bio_resid; |
149 |
|
172 |
|
150 |
dsz = aoenet_maxsize(d->ad_ifp); |
173 |
dsz = aoenet_maxsize(d->ad_ifp); |
151 |
if (bcnt > dsz) |
174 |
if (bcnt > dsz) |
152 |
bcnt = dsz; |
175 |
bcnt = dsz; |
153 |
|
176 |
|
|
|
177 |
|
178 |
|
154 |
/* Initialize the headers & frame. */ |
179 |
/* Initialize the headers & frame. */ |
155 |
h = (struct aoe_hdr *) f->f_hdr; |
180 |
h = (struct aoe_hdr *) f->f_hdr; |
156 |
ah = (struct aoe_atahdr *) (h+1); |
181 |
ah = (struct aoe_atahdr *) (h+1); |
Lines 188-195
Link Here
|
188 |
if (bp->bio_resid == 0) /* We have satisfied strategy bio. */ |
213 |
if (bp->bio_resid == 0) /* We have satisfied strategy bio. */ |
189 |
d->ad_inprocess = NULL; |
214 |
d->ad_inprocess = NULL; |
190 |
|
215 |
|
191 |
if(aoenet_xmitframe(d, f)) |
216 |
aoenet_xmitframe(d, f); |
192 |
IPRINTK("Could not send frame\n"); |
|
|
193 |
} |
217 |
} |
194 |
|
218 |
|
195 |
static void |
219 |
static void |
Lines 217-224
Link Here
|
217 |
f->f_tag = newtag(d); |
241 |
f->f_tag = newtag(d); |
218 |
h->ah_tag = htonl(f->f_tag); |
242 |
h->ah_tag = htonl(f->f_tag); |
219 |
|
243 |
|
220 |
if (aoenet_xmitframe(d, f)) |
244 |
aoenet_xmitframe(d, f); |
221 |
IPRINTK("Could not send frame\n"); |
|
|
222 |
} |
245 |
} |
223 |
|
246 |
|
224 |
/* How long since we sent this tag? */ |
247 |
/* How long since we sent this tag? */ |
Lines 306-313
Link Here
|
306 |
ah->aa_errfeat = aoe_wc ? ATA_SF_ENAB_WCACHE : ATA_SF_DIS_WCACHE; |
329 |
ah->aa_errfeat = aoe_wc ? ATA_SF_ENAB_WCACHE : ATA_SF_DIS_WCACHE; |
307 |
ah->aa_lba3 = 0xa0; /* Obsolete bits per ATA6. */ |
330 |
ah->aa_lba3 = 0xa0; /* Obsolete bits per ATA6. */ |
308 |
|
331 |
|
309 |
if (aoenet_xmitframe(d, f)) |
332 |
aoenet_xmitframe(d, f); |
310 |
IPRINTK("Could not send frame\n"); |
|
|
311 |
} |
333 |
} |
312 |
|
334 |
|
313 |
/* Command to send an ATA identify. */ |
335 |
/* Command to send an ATA identify. */ |
Lines 343-349
Link Here
|
343 |
ah->aa_lba3 = 0xa0; |
365 |
ah->aa_lba3 = 0xa0; |
344 |
|
366 |
|
345 |
if (aoenet_xmitframe(d, f)) { |
367 |
if (aoenet_xmitframe(d, f)) { |
346 |
IPRINTK("Could not send frame\n"); |
|
|
347 |
return; |
368 |
return; |
348 |
} |
369 |
} |
349 |
|
370 |
|
Lines 358-374
Link Here
|
358 |
struct aoe_hdr *h; |
379 |
struct aoe_hdr *h; |
359 |
struct aoe_cfghdr *ch; |
380 |
struct aoe_cfghdr *ch; |
360 |
u_long unit, bufcnt; |
381 |
u_long unit, bufcnt; |
361 |
enum { MAXFRAMES = 8 }; |
382 |
enum { MAXFRAMES = 256 }; |
362 |
|
383 |
|
363 |
h = mtod(m, struct aoe_hdr *); |
384 |
h = mtod(m, struct aoe_hdr *); |
364 |
ch = (struct aoe_cfghdr *) (h+1); |
385 |
ch = (struct aoe_cfghdr *) (h+1); |
365 |
|
386 |
|
366 |
unit = AOEUNIT(ntohs(h->ah_major), h->ah_minor); |
387 |
if(h->ah_minor>MINPERMAJ-1) { |
|
|
388 |
EPRINTK("AoE minor id %d > %d (maximum allowed), ignoring\n", |
389 |
h->ah_minor, |
390 |
MINPERMAJ-1); |
391 |
return; |
392 |
} |
367 |
|
393 |
|
368 |
bufcnt = ntohs(ch->ac_bufcnt); |
394 |
bufcnt = ntohs(ch->ac_bufcnt); |
369 |
if (bufcnt > MAXFRAMES) /* Let's keep it reasonable. */ |
395 |
if (bufcnt > MAXFRAMES) { /* Let's keep it reasonable. */ |
|
|
396 |
EPRINTK("bufcnt=%ld > %d, truncated.\n",bufcnt,MAXFRAMES); |
370 |
bufcnt = MAXFRAMES; |
397 |
bufcnt = MAXFRAMES; |
371 |
|
398 |
} |
|
|
399 |
|
400 |
unit = AOEUNIT(ntohs(h->ah_major), h->ah_minor); |
401 |
|
372 |
d = aoedev_set(unit, h->ah_src, m->m_pkthdr.rcvif, bufcnt); |
402 |
d = aoedev_set(unit, h->ah_src, m->m_pkthdr.rcvif, bufcnt); |
373 |
if (d == NULL) { |
403 |
if (d == NULL) { |
374 |
IPRINTK("failure setting device\n"); |
404 |
IPRINTK("failure setting device\n"); |
Lines 427-469
Link Here
|
427 |
goto loop; |
457 |
goto loop; |
428 |
} |
458 |
} |
429 |
|
459 |
|
430 |
static u_short |
|
|
431 |
lhget16(u_char *p) |
432 |
{ |
433 |
u_short n; |
434 |
|
435 |
n = p[1]; |
436 |
n <<= 8; |
437 |
n |= p[0]; |
438 |
return (n); |
439 |
} |
440 |
|
441 |
static u_long |
442 |
lhget32(u_char *p) |
443 |
{ |
444 |
u_long n; |
445 |
|
446 |
n = lhget16(p+2); |
447 |
n <<= 16; |
448 |
n |= lhget16(p); |
449 |
return (n); |
450 |
} |
451 |
|
452 |
|
453 |
static void |
460 |
static void |
454 |
ataid_complete(struct aoedev *d, char *id) |
461 |
ataid_complete(struct aoedev *d, char *id) |
455 |
{ |
462 |
{ |
456 |
int n; |
463 |
int n; |
457 |
|
464 |
|
458 |
memcpy(d->ad_ident, id, sizeof d->ad_ident); |
465 |
memcpy(d->ad_ident, id, sizeof d->ad_ident); |
459 |
|
466 |
|
460 |
n = lhget16(id + (83<<1)); /* Command set supported. */ |
467 |
n = le16toh(*(uint16_t *) (id + (83<<1))); /* Command set supported. */ |
461 |
if (n & (1<<10)) { /* Lba48 */ |
468 |
if (n & (1<<10)) { /* Lba48 */ |
462 |
atomic_set_32(&d->ad_flags, DEVFL_EXT); |
469 |
atomic_set_32(&d->ad_flags, DEVFL_EXT); |
463 |
d->ad_nsectors = lhget32(id + (100<<1)); /* n lba48 sectors. */ |
470 |
d->ad_nsectors = le64toh(*(uint64_t *) (id + (100<<1))); /* n lba48 sectors. */ |
464 |
} else { |
471 |
} else { |
465 |
atomic_clear_32(&d->ad_flags, DEVFL_EXT); |
472 |
atomic_clear_32(&d->ad_flags, DEVFL_EXT); |
466 |
d->ad_nsectors = lhget32(id + (60<<1)); /* n lba28 sectors. */ |
473 |
d->ad_nsectors = le32toh(*(uint32_t *) (id + (60<<1))); /* n lba28 sectors. */ |
467 |
} |
474 |
} |
468 |
if (aoeblk_register(d) != 0) |
475 |
if (aoeblk_register(d) != 0) |
469 |
IPRINTK("could not register disk\n"); |
476 |
IPRINTK("could not register disk\n"); |
Lines 519-526
Link Here
|
519 |
if (f == NULL) { |
526 |
if (f == NULL) { |
520 |
calc_rttavg(d, -tsince(n)); |
527 |
calc_rttavg(d, -tsince(n)); |
521 |
mtx_unlock(&d->ad_mtx); |
528 |
mtx_unlock(&d->ad_mtx); |
522 |
IPRINTK("unsolicited response from %d.%d\n", |
529 |
//IPRINTK("unsolicited response from %d.%d\n", |
523 |
ntohs(hin->ah_major), hin->ah_minor); |
530 |
// ntohs(hin->ah_major), hin->ah_minor); |
524 |
return; |
531 |
return; |
525 |
} |
532 |
} |
526 |
|
533 |
|
Lines 642-649
Link Here
|
642 |
lba = iocmd->ata_ioc_request_ata.lba; |
649 |
lba = iocmd->ata_ioc_request_ata.lba; |
643 |
put_lba(ah, lba); |
650 |
put_lba(ah, lba); |
644 |
|
651 |
|
645 |
if (aoenet_xmitframe(d, f)) |
652 |
aoenet_xmitframe(d, f); |
646 |
IPRINTK("Could not send frame\n"); |
|
|
647 |
|
653 |
|
648 |
if (msleep(d, &d->ad_mtx, 0, "aoesmt", timeout) == EWOULDBLOCK) { |
654 |
if (msleep(d, &d->ad_mtx, 0, "aoesmt", timeout) == EWOULDBLOCK) { |
649 |
f->f_tag = FREETAG; |
655 |
f->f_tag = FREETAG; |