usb_ethernet.c (188942) | usb_ethernet.c (189528) |
---|---|
1/* $FreeBSD: head/sys/dev/usb/net/usb_ethernet.c 188942 2009-02-23 18:31:00Z thompsa $ */ | 1/* $FreeBSD: head/sys/dev/usb/net/usb_ethernet.c 189528 2009-03-08 06:56:13Z thompsa $ */ |
2/*- 3 * Copyright (c) 2009 Andrew Thompson (thompsa@FreeBSD.org) 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. --- 497 unchanged lines hidden (view full) --- 507 return (0); 508} 509static moduledata_t usb2_ether_mod = { 510 "uether", 511 usb2_ether_modevent, 512 0 513}; 514 | 2/*- 3 * Copyright (c) 2009 Andrew Thompson (thompsa@FreeBSD.org) 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. --- 497 unchanged lines hidden (view full) --- 507 return (0); 508} 509static moduledata_t usb2_ether_mod = { 510 "uether", 511 usb2_ether_modevent, 512 0 513}; 514 |
515struct mbuf * 516usb2_ether_newbuf(void) 517{ 518 struct mbuf *m_new; 519 520 m_new = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); 521 if (m_new == NULL) 522 return (NULL); 523 m_new->m_len = m_new->m_pkthdr.len = MCLBYTES; 524 525 m_adj(m_new, ETHER_ALIGN); 526 return (m_new); 527} 528 |
|
515int 516usb2_ether_rxmbuf(struct usb2_ether *ue, struct mbuf *m, 517 unsigned int len) 518{ 519 struct ifnet *ifp = ue->ue_ifp; 520 521 UE_LOCK_ASSERT(ue, MA_OWNED); 522 --- 11 unchanged lines hidden (view full) --- 534usb2_ether_rxbuf(struct usb2_ether *ue, struct usb2_page_cache *pc, 535 unsigned int offset, unsigned int len) 536{ 537 struct ifnet *ifp = ue->ue_ifp; 538 struct mbuf *m; 539 540 UE_LOCK_ASSERT(ue, MA_OWNED); 541 | 529int 530usb2_ether_rxmbuf(struct usb2_ether *ue, struct mbuf *m, 531 unsigned int len) 532{ 533 struct ifnet *ifp = ue->ue_ifp; 534 535 UE_LOCK_ASSERT(ue, MA_OWNED); 536 --- 11 unchanged lines hidden (view full) --- 548usb2_ether_rxbuf(struct usb2_ether *ue, struct usb2_page_cache *pc, 549 unsigned int offset, unsigned int len) 550{ 551 struct ifnet *ifp = ue->ue_ifp; 552 struct mbuf *m; 553 554 UE_LOCK_ASSERT(ue, MA_OWNED); 555 |
542 if (len < ETHER_HDR_LEN || len > MCLBYTES) | 556 if (len < ETHER_HDR_LEN || len > MCLBYTES - ETHER_ALIGN) |
543 return (1); 544 | 557 return (1); 558 |
545 m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); | 559 m = usb2_ether_newbuf(); |
546 if (m == NULL) { 547 ifp->if_ierrors++; 548 return (ENOMEM); 549 } 550 | 560 if (m == NULL) { 561 ifp->if_ierrors++; 562 return (ENOMEM); 563 } 564 |
551 m_adj(m, ETHER_ALIGN); | |
552 usb2_copy_out(pc, offset, mtod(m, uint8_t *), len); 553 554 /* finalize mbuf */ 555 ifp->if_ipackets++; 556 m->m_pkthdr.rcvif = ifp; 557 m->m_pkthdr.len = m->m_len = len; 558 559 /* enqueue for later when the lock can be released */ --- 28 unchanged lines hidden --- | 565 usb2_copy_out(pc, offset, mtod(m, uint8_t *), len); 566 567 /* finalize mbuf */ 568 ifp->if_ipackets++; 569 m->m_pkthdr.rcvif = ifp; 570 m->m_pkthdr.len = m->m_len = len; 571 572 /* enqueue for later when the lock can be released */ --- 28 unchanged lines hidden --- |