if_vte.c (8fa0b743820f61c661ba5f3ea0e3be0dc137910e) | if_vte.c (c6499eccad497913a5025fbde8ae76da70e08043) |
---|---|
1/*- 2 * Copyright (c) 2010, Pyun YongHyeon <yongari@FreeBSD.org> 3 * All rights reserved. 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 --- 1020 unchanged lines hidden (view full) --- 1029 bzero(mtod(m, char *) + m->m_pkthdr.len, padlen); 1030 m->m_pkthdr.len += padlen; 1031 m->m_len = m->m_pkthdr.len; 1032 } 1033 } else { 1034 if (M_WRITABLE(m) == 0) { 1035 if (m->m_next != NULL || padlen > 0) { 1036 /* Get a writable copy. */ | 1/*- 2 * Copyright (c) 2010, Pyun YongHyeon <yongari@FreeBSD.org> 3 * All rights reserved. 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 --- 1020 unchanged lines hidden (view full) --- 1029 bzero(mtod(m, char *) + m->m_pkthdr.len, padlen); 1030 m->m_pkthdr.len += padlen; 1031 m->m_len = m->m_pkthdr.len; 1032 } 1033 } else { 1034 if (M_WRITABLE(m) == 0) { 1035 if (m->m_next != NULL || padlen > 0) { 1036 /* Get a writable copy. */ |
1037 m = m_dup(*m_head, M_DONTWAIT); | 1037 m = m_dup(*m_head, M_NOWAIT); |
1038 /* Release original mbuf chains. */ 1039 m_freem(*m_head); 1040 if (m == NULL) { 1041 *m_head = NULL; 1042 return (NULL); 1043 } 1044 *m_head = m; 1045 } 1046 } 1047 1048 if (m->m_next != NULL) { | 1038 /* Release original mbuf chains. */ 1039 m_freem(*m_head); 1040 if (m == NULL) { 1041 *m_head = NULL; 1042 return (NULL); 1043 } 1044 *m_head = m; 1045 } 1046 } 1047 1048 if (m->m_next != NULL) { |
1049 m = m_defrag(*m_head, M_DONTWAIT); | 1049 m = m_defrag(*m_head, M_NOWAIT); |
1050 if (m == NULL) { 1051 m_freem(*m_head); 1052 *m_head = NULL; 1053 return (NULL); 1054 } 1055 *m_head = m; 1056 } 1057 1058 if (padlen > 0) { 1059 if (M_TRAILINGSPACE(m) < padlen) { | 1050 if (m == NULL) { 1051 m_freem(*m_head); 1052 *m_head = NULL; 1053 return (NULL); 1054 } 1055 *m_head = m; 1056 } 1057 1058 if (padlen > 0) { 1059 if (M_TRAILINGSPACE(m) < padlen) { |
1060 m = m_defrag(*m_head, M_DONTWAIT); | 1060 m = m_defrag(*m_head, M_NOWAIT); |
1061 if (m == NULL) { 1062 m_freem(*m_head); 1063 *m_head = NULL; 1064 return (NULL); 1065 } 1066 *m_head = m; 1067 } 1068 /* Zero out the bytes in the pad area. */ --- 348 unchanged lines hidden (view full) --- 1417static int 1418vte_newbuf(struct vte_softc *sc, struct vte_rxdesc *rxd) 1419{ 1420 struct mbuf *m; 1421 bus_dma_segment_t segs[1]; 1422 bus_dmamap_t map; 1423 int nsegs; 1424 | 1061 if (m == NULL) { 1062 m_freem(*m_head); 1063 *m_head = NULL; 1064 return (NULL); 1065 } 1066 *m_head = m; 1067 } 1068 /* Zero out the bytes in the pad area. */ --- 348 unchanged lines hidden (view full) --- 1417static int 1418vte_newbuf(struct vte_softc *sc, struct vte_rxdesc *rxd) 1419{ 1420 struct mbuf *m; 1421 bus_dma_segment_t segs[1]; 1422 bus_dmamap_t map; 1423 int nsegs; 1424 |
1425 m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); | 1425 m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); |
1426 if (m == NULL) 1427 return (ENOBUFS); 1428 m->m_len = m->m_pkthdr.len = MCLBYTES; 1429 m_adj(m, sizeof(uint32_t)); 1430 1431 if (bus_dmamap_load_mbuf_sg(sc->vte_cdata.vte_rx_tag, 1432 sc->vte_cdata.vte_rx_sparemap, m, segs, &nsegs, 0) != 0) { 1433 m_freem(m); --- 431 unchanged lines hidden (view full) --- 1865 1866 sc->vte_cdata.vte_tx_prod = 0; 1867 sc->vte_cdata.vte_tx_cons = 0; 1868 sc->vte_cdata.vte_tx_cnt = 0; 1869 1870 /* Pre-allocate TX mbufs for deep copy. */ 1871 if (tx_deep_copy != 0) { 1872 for (i = 0; i < VTE_TX_RING_CNT; i++) { | 1426 if (m == NULL) 1427 return (ENOBUFS); 1428 m->m_len = m->m_pkthdr.len = MCLBYTES; 1429 m_adj(m, sizeof(uint32_t)); 1430 1431 if (bus_dmamap_load_mbuf_sg(sc->vte_cdata.vte_rx_tag, 1432 sc->vte_cdata.vte_rx_sparemap, m, segs, &nsegs, 0) != 0) { 1433 m_freem(m); --- 431 unchanged lines hidden (view full) --- 1865 1866 sc->vte_cdata.vte_tx_prod = 0; 1867 sc->vte_cdata.vte_tx_cons = 0; 1868 sc->vte_cdata.vte_tx_cnt = 0; 1869 1870 /* Pre-allocate TX mbufs for deep copy. */ 1871 if (tx_deep_copy != 0) { 1872 for (i = 0; i < VTE_TX_RING_CNT; i++) { |
1873 sc->vte_cdata.vte_txmbufs[i] = m_getcl(M_DONTWAIT, | 1873 sc->vte_cdata.vte_txmbufs[i] = m_getcl(M_NOWAIT, |
1874 MT_DATA, M_PKTHDR); 1875 if (sc->vte_cdata.vte_txmbufs[i] == NULL) 1876 return (ENOBUFS); 1877 sc->vte_cdata.vte_txmbufs[i]->m_pkthdr.len = MCLBYTES; 1878 sc->vte_cdata.vte_txmbufs[i]->m_len = MCLBYTES; 1879 } 1880 } 1881 desc = sc->vte_cdata.vte_tx_ring; --- 167 unchanged lines hidden --- | 1874 MT_DATA, M_PKTHDR); 1875 if (sc->vte_cdata.vte_txmbufs[i] == NULL) 1876 return (ENOBUFS); 1877 sc->vte_cdata.vte_txmbufs[i]->m_pkthdr.len = MCLBYTES; 1878 sc->vte_cdata.vte_txmbufs[i]->m_len = MCLBYTES; 1879 } 1880 } 1881 desc = sc->vte_cdata.vte_tx_ring; --- 167 unchanged lines hidden --- |