Tue Jul 31 09:19:34 2018 UTC ()
 Make jcl allocation per queue to reduce mutex spin. Tested by me and
knakahara.


(msaitoh)
diff -r1.48 -r1.49 src/sys/dev/pci/ixgbe/ix_txrx.c
diff -r1.50 -r1.51 src/sys/dev/pci/ixgbe/ixgbe.h
diff -r1.7 -r1.8 src/sys/dev/pci/ixgbe/ixgbe_netbsd.c
diff -r1.22 -r1.23 src/sys/dev/pci/ixgbe/ixgbe_osdep.h

cvs diff -r1.48 -r1.49 src/sys/dev/pci/ixgbe/ix_txrx.c (expand / switch to unified diff)

--- src/sys/dev/pci/ixgbe/ix_txrx.c 2018/06/26 06:48:01 1.48
+++ src/sys/dev/pci/ixgbe/ix_txrx.c 2018/07/31 09:19:34 1.49
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ix_txrx.c,v 1.48 2018/06/26 06:48:01 msaitoh Exp $ */ 1/* $NetBSD: ix_txrx.c,v 1.49 2018/07/31 09:19:34 msaitoh Exp $ */
2 2
3/****************************************************************************** 3/******************************************************************************
4 4
5 Copyright (c) 2001-2017, Intel Corporation 5 Copyright (c) 2001-2017, Intel Corporation
6 All rights reserved. 6 All rights reserved.
7 7
8 Redistribution and use in source and binary forms, with or without 8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met: 9 modification, are permitted provided that the following conditions are met:
10 10
11 1. Redistributions of source code must retain the above copyright notice, 11 1. Redistributions of source code must retain the above copyright notice,
12 this list of conditions and the following disclaimer. 12 this list of conditions and the following disclaimer.
13 13
14 2. Redistributions in binary form must reproduce the above copyright 14 2. Redistributions in binary form must reproduce the above copyright
@@ -1333,27 +1333,27 @@ ixgbe_refresh_mbufs(struct rx_ring *rxr, @@ -1333,27 +1333,27 @@ ixgbe_refresh_mbufs(struct rx_ring *rxr,
1333 struct ixgbe_rx_buf *rxbuf; 1333 struct ixgbe_rx_buf *rxbuf;
1334 struct mbuf *mp; 1334 struct mbuf *mp;
1335 int i, j, error; 1335 int i, j, error;
1336 bool refreshed = false; 1336 bool refreshed = false;
1337 1337
1338 i = j = rxr->next_to_refresh; 1338 i = j = rxr->next_to_refresh;
1339 /* Control the loop with one beyond */ 1339 /* Control the loop with one beyond */
1340 if (++j == rxr->num_desc) 1340 if (++j == rxr->num_desc)
1341 j = 0; 1341 j = 0;
1342 1342
1343 while (j != limit) { 1343 while (j != limit) {
1344 rxbuf = &rxr->rx_buffers[i]; 1344 rxbuf = &rxr->rx_buffers[i];
1345 if (rxbuf->buf == NULL) { 1345 if (rxbuf->buf == NULL) {
1346 mp = ixgbe_getjcl(&adapter->jcl_head, M_NOWAIT, 1346 mp = ixgbe_getjcl(&rxr->jcl_head, M_NOWAIT,
1347 MT_DATA, M_PKTHDR, rxr->mbuf_sz); 1347 MT_DATA, M_PKTHDR, rxr->mbuf_sz);
1348 if (mp == NULL) { 1348 if (mp == NULL) {
1349 rxr->no_jmbuf.ev_count++; 1349 rxr->no_jmbuf.ev_count++;
1350 goto update; 1350 goto update;
1351 } 1351 }
1352 if (adapter->max_frame_size <= (MCLBYTES - ETHER_ALIGN)) 1352 if (adapter->max_frame_size <= (MCLBYTES - ETHER_ALIGN))
1353 m_adj(mp, ETHER_ALIGN); 1353 m_adj(mp, ETHER_ALIGN);
1354 } else 1354 } else
1355 mp = rxbuf->buf; 1355 mp = rxbuf->buf;
1356 1356
1357 mp->m_pkthdr.len = mp->m_len = rxr->mbuf_sz; 1357 mp->m_pkthdr.len = mp->m_len = rxr->mbuf_sz;
1358 1358
1359 /* If we're dealing with an mbuf that was copied rather 1359 /* If we're dealing with an mbuf that was copied rather
@@ -1495,26 +1495,37 @@ ixgbe_setup_receive_ring(struct rx_ring  @@ -1495,26 +1495,37 @@ ixgbe_setup_receive_ring(struct rx_ring
1495 if (adapter->feat_en & IXGBE_FEATURE_NETMAP) 1495 if (adapter->feat_en & IXGBE_FEATURE_NETMAP)
1496 slot = netmap_reset(na, NR_RX, rxr->me, 0); 1496 slot = netmap_reset(na, NR_RX, rxr->me, 0);
1497#endif /* DEV_NETMAP */ 1497#endif /* DEV_NETMAP */
1498 1498
1499 rsize = roundup2(adapter->num_rx_desc * 1499 rsize = roundup2(adapter->num_rx_desc *
1500 sizeof(union ixgbe_adv_rx_desc), DBA_ALIGN); 1500 sizeof(union ixgbe_adv_rx_desc), DBA_ALIGN);
1501 bzero((void *)rxr->rx_base, rsize); 1501 bzero((void *)rxr->rx_base, rsize);
1502 /* Cache the size */ 1502 /* Cache the size */
1503 rxr->mbuf_sz = adapter->rx_mbuf_sz; 1503 rxr->mbuf_sz = adapter->rx_mbuf_sz;
1504 1504
1505 /* Free current RX buffer structs and their mbufs */ 1505 /* Free current RX buffer structs and their mbufs */
1506 ixgbe_free_receive_ring(rxr); 1506 ixgbe_free_receive_ring(rxr);
1507 1507
 1508 IXGBE_RX_UNLOCK(rxr);
 1509 /*
 1510 * Now reinitialize our supply of jumbo mbufs. The number
 1511 * or size of jumbo mbufs may have changed.
 1512 * Assume all of rxr->ptag are the same.
 1513 */
 1514 ixgbe_jcl_reinit(adapter, rxr->ptag->dt_dmat, rxr,
 1515 (2 * adapter->num_rx_desc), adapter->rx_mbuf_sz);
 1516
 1517 IXGBE_RX_LOCK(rxr);
 1518
1508 /* Now replenish the mbufs */ 1519 /* Now replenish the mbufs */
1509 for (int j = 0; j != rxr->num_desc; ++j) { 1520 for (int j = 0; j != rxr->num_desc; ++j) {
1510 struct mbuf *mp; 1521 struct mbuf *mp;
1511 1522
1512 rxbuf = &rxr->rx_buffers[j]; 1523 rxbuf = &rxr->rx_buffers[j];
1513 1524
1514#ifdef DEV_NETMAP 1525#ifdef DEV_NETMAP
1515 /* 1526 /*
1516 * In netmap mode, fill the map and set the buffer 1527 * In netmap mode, fill the map and set the buffer
1517 * address in the NIC ring, considering the offset 1528 * address in the NIC ring, considering the offset
1518 * between the netmap and NIC rings (see comment in 1529 * between the netmap and NIC rings (see comment in
1519 * ixgbe_setup_transmit_ring() ). No need to allocate 1530 * ixgbe_setup_transmit_ring() ). No need to allocate
1520 * an mbuf, so end the block with a continue; 1531 * an mbuf, so end the block with a continue;
@@ -1524,27 +1535,27 @@ ixgbe_setup_receive_ring(struct rx_ring  @@ -1524,27 +1535,27 @@ ixgbe_setup_receive_ring(struct rx_ring
1524 uint64_t paddr; 1535 uint64_t paddr;
1525 void *addr; 1536 void *addr;
1526 1537
1527 addr = PNMB(na, slot + sj, &paddr); 1538 addr = PNMB(na, slot + sj, &paddr);
1528 netmap_load_map(na, rxr->ptag, rxbuf->pmap, addr); 1539 netmap_load_map(na, rxr->ptag, rxbuf->pmap, addr);
1529 /* Update descriptor and the cached value */ 1540 /* Update descriptor and the cached value */
1530 rxr->rx_base[j].read.pkt_addr = htole64(paddr); 1541 rxr->rx_base[j].read.pkt_addr = htole64(paddr);
1531 rxbuf->addr = htole64(paddr); 1542 rxbuf->addr = htole64(paddr);
1532 continue; 1543 continue;
1533 } 1544 }
1534#endif /* DEV_NETMAP */ 1545#endif /* DEV_NETMAP */
1535 1546
1536 rxbuf->flags = 0; 1547 rxbuf->flags = 0;
1537 rxbuf->buf = ixgbe_getjcl(&adapter->jcl_head, M_NOWAIT, 1548 rxbuf->buf = ixgbe_getjcl(&rxr->jcl_head, M_NOWAIT,
1538 MT_DATA, M_PKTHDR, adapter->rx_mbuf_sz); 1549 MT_DATA, M_PKTHDR, adapter->rx_mbuf_sz);
1539 if (rxbuf->buf == NULL) { 1550 if (rxbuf->buf == NULL) {
1540 error = ENOBUFS; 1551 error = ENOBUFS;
1541 goto fail; 1552 goto fail;
1542 } 1553 }
1543 mp = rxbuf->buf; 1554 mp = rxbuf->buf;
1544 mp->m_pkthdr.len = mp->m_len = rxr->mbuf_sz; 1555 mp->m_pkthdr.len = mp->m_len = rxr->mbuf_sz;
1545 /* Get the memory mapping */ 1556 /* Get the memory mapping */
1546 error = bus_dmamap_load_mbuf(rxr->ptag->dt_dmat, rxbuf->pmap, 1557 error = bus_dmamap_load_mbuf(rxr->ptag->dt_dmat, rxbuf->pmap,
1547 mp, BUS_DMA_NOWAIT); 1558 mp, BUS_DMA_NOWAIT);
1548 if (error != 0) 1559 if (error != 0)
1549 goto fail; 1560 goto fail;
1550 bus_dmamap_sync(rxr->ptag->dt_dmat, rxbuf->pmap, 1561 bus_dmamap_sync(rxr->ptag->dt_dmat, rxbuf->pmap,
@@ -1601,35 +1612,26 @@ fail: @@ -1601,35 +1612,26 @@ fail:
1601 1612
1602 return (error); 1613 return (error);
1603} /* ixgbe_setup_receive_ring */ 1614} /* ixgbe_setup_receive_ring */
1604 1615
1605/************************************************************************ 1616/************************************************************************
1606 * ixgbe_setup_receive_structures - Initialize all receive rings. 1617 * ixgbe_setup_receive_structures - Initialize all receive rings.
1607 ************************************************************************/ 1618 ************************************************************************/
1608int 1619int
1609ixgbe_setup_receive_structures(struct adapter *adapter) 1620ixgbe_setup_receive_structures(struct adapter *adapter)
1610{ 1621{
1611 struct rx_ring *rxr = adapter->rx_rings; 1622 struct rx_ring *rxr = adapter->rx_rings;
1612 int j; 1623 int j;
1613 1624
1614 /* 
1615 * Now reinitialize our supply of jumbo mbufs. The number 
1616 * or size of jumbo mbufs may have changed. 
1617 * Assume all of rxr->ptag are the same. 
1618 */ 
1619 ixgbe_jcl_reinit(adapter, rxr->ptag->dt_dmat, 
1620 (2 * adapter->num_rx_desc) * adapter->num_queues, 
1621 adapter->rx_mbuf_sz); 
1622 
1623 for (j = 0; j < adapter->num_queues; j++, rxr++) 1625 for (j = 0; j < adapter->num_queues; j++, rxr++)
1624 if (ixgbe_setup_receive_ring(rxr)) 1626 if (ixgbe_setup_receive_ring(rxr))
1625 goto fail; 1627 goto fail;
1626 1628
1627 return (0); 1629 return (0);
1628fail: 1630fail:
1629 /* 1631 /*
1630 * Free RX buffers allocated so far, we will only handle 1632 * Free RX buffers allocated so far, we will only handle
1631 * the rings that completed, the failing case will have 1633 * the rings that completed, the failing case will have
1632 * cleaned up for itself. 'j' failed, so its the terminus. 1634 * cleaned up for itself. 'j' failed, so its the terminus.
1633 */ 1635 */
1634 for (int i = 0; i < j; ++i) { 1636 for (int i = 0; i < j; ++i) {
1635 rxr = &adapter->rx_rings[i]; 1637 rxr = &adapter->rx_rings[i];

cvs diff -r1.50 -r1.51 src/sys/dev/pci/ixgbe/ixgbe.h (expand / switch to unified diff)

--- src/sys/dev/pci/ixgbe/ixgbe.h 2018/06/25 05:06:10 1.50
+++ src/sys/dev/pci/ixgbe/ixgbe.h 2018/07/31 09:19:34 1.51
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ixgbe.h,v 1.50 2018/06/25 05:06:10 msaitoh Exp $ */ 1/* $NetBSD: ixgbe.h,v 1.51 2018/07/31 09:19:34 msaitoh Exp $ */
2 2
3/****************************************************************************** 3/******************************************************************************
4 SPDX-License-Identifier: BSD-3-Clause 4 SPDX-License-Identifier: BSD-3-Clause
5 5
6 Copyright (c) 2001-2017, Intel Corporation 6 Copyright (c) 2001-2017, Intel Corporation
7 All rights reserved. 7 All rights reserved.
8 8
9 Redistribution and use in source and binary forms, with or without 9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are met: 10 modification, are permitted provided that the following conditions are met:
11 11
12 1. Redistributions of source code must retain the above copyright notice, 12 1. Redistributions of source code must retain the above copyright notice,
13 this list of conditions and the following disclaimer. 13 this list of conditions and the following disclaimer.
14 14
@@ -407,26 +407,29 @@ struct rx_ring { @@ -407,26 +407,29 @@ struct rx_ring {
407#endif /* LRO */ 407#endif /* LRO */
408 bool lro_enabled; 408 bool lro_enabled;
409 bool hw_rsc; 409 bool hw_rsc;
410 bool vtag_strip; 410 bool vtag_strip;
411 u16 next_to_refresh; 411 u16 next_to_refresh;
412 u16 next_to_check; 412 u16 next_to_check;
413 u16 num_desc; 413 u16 num_desc;
414 u16 mbuf_sz; 414 u16 mbuf_sz;
415#if 0 415#if 0
416 char mtx_name[16]; /* NetBSD has no mutex name */ 416 char mtx_name[16]; /* NetBSD has no mutex name */
417#endif 417#endif
418 struct ixgbe_rx_buf *rx_buffers; 418 struct ixgbe_rx_buf *rx_buffers;
419 ixgbe_dma_tag_t *ptag; 419 ixgbe_dma_tag_t *ptag;
 420 u16 last_rx_mbuf_sz;
 421 u32 last_num_rx_desc;
 422 ixgbe_extmem_head_t jcl_head;
420 423
421 u64 bytes; /* Used for AIM calc */ 424 u64 bytes; /* Used for AIM calc */
422 u64 packets; 425 u64 packets;
423 426
424 /* Soft stats */ 427 /* Soft stats */
425 struct evcnt rx_copies; 428 struct evcnt rx_copies;
426 struct evcnt rx_packets; 429 struct evcnt rx_packets;
427 struct evcnt rx_bytes; 430 struct evcnt rx_bytes;
428 struct evcnt rx_discarded; 431 struct evcnt rx_discarded;
429 struct evcnt no_jmbuf; 432 struct evcnt no_jmbuf;
430 u64 rsc_num; 433 u64 rsc_num;
431 434
432 /* Flow Director */ 435 /* Flow Director */
@@ -592,27 +595,26 @@ struct adapter { @@ -592,27 +595,26 @@ struct adapter {
592 u64 ibytes; 595 u64 ibytes;
593 u64 obytes; 596 u64 obytes;
594 u64 imcasts; 597 u64 imcasts;
595 u64 omcasts; 598 u64 omcasts;
596 u64 iqdrops; 599 u64 iqdrops;
597 u64 noproto; 600 u64 noproto;
598#endif 601#endif
599 /* Feature capable/enabled flags. See ixgbe_features.h */ 602 /* Feature capable/enabled flags. See ixgbe_features.h */
600 u32 feat_cap; 603 u32 feat_cap;
601 u32 feat_en; 604 u32 feat_en;
602 605
603 struct sysctllog *sysctllog; 606 struct sysctllog *sysctllog;
604 const struct sysctlnode *sysctltop; 607 const struct sysctlnode *sysctltop;
605 ixgbe_extmem_head_t jcl_head; 
606}; 608};
607 609
608/* Precision Time Sync (IEEE 1588) defines */ 610/* Precision Time Sync (IEEE 1588) defines */
609#define ETHERTYPE_IEEE1588 0x88F7 611#define ETHERTYPE_IEEE1588 0x88F7
610#define PICOSECS_PER_TICK 20833 612#define PICOSECS_PER_TICK 20833
611#define TSYNC_UDP_PORT 319 /* UDP port for the protocol */ 613#define TSYNC_UDP_PORT 319 /* UDP port for the protocol */
612#define IXGBE_ADVTXD_TSTAMP 0x00080000 614#define IXGBE_ADVTXD_TSTAMP 0x00080000
613 615
614 616
615#define IXGBE_CORE_LOCK_INIT(_sc, _name) \ 617#define IXGBE_CORE_LOCK_INIT(_sc, _name) \
616 mutex_init(&(_sc)->core_mtx, MUTEX_DEFAULT, IPL_SOFTNET) 618 mutex_init(&(_sc)->core_mtx, MUTEX_DEFAULT, IPL_SOFTNET)
617#define IXGBE_CORE_LOCK_DESTROY(_sc) mutex_destroy(&(_sc)->core_mtx) 619#define IXGBE_CORE_LOCK_DESTROY(_sc) mutex_destroy(&(_sc)->core_mtx)
618#define IXGBE_TX_LOCK_DESTROY(_sc) mutex_destroy(&(_sc)->tx_mtx) 620#define IXGBE_TX_LOCK_DESTROY(_sc) mutex_destroy(&(_sc)->tx_mtx)
@@ -742,21 +744,22 @@ void ixgbe_deferred_mq_start_work(struct @@ -742,21 +744,22 @@ void ixgbe_deferred_mq_start_work(struct
742void ixgbe_drain_all(struct adapter *); 744void ixgbe_drain_all(struct adapter *);
743 745
744int ixgbe_allocate_queues(struct adapter *); 746int ixgbe_allocate_queues(struct adapter *);
745int ixgbe_setup_transmit_structures(struct adapter *); 747int ixgbe_setup_transmit_structures(struct adapter *);
746void ixgbe_free_transmit_structures(struct adapter *); 748void ixgbe_free_transmit_structures(struct adapter *);
747int ixgbe_setup_receive_structures(struct adapter *); 749int ixgbe_setup_receive_structures(struct adapter *);
748void ixgbe_free_receive_structures(struct adapter *); 750void ixgbe_free_receive_structures(struct adapter *);
749bool ixgbe_txeof(struct tx_ring *); 751bool ixgbe_txeof(struct tx_ring *);
750bool ixgbe_rxeof(struct ix_queue *); 752bool ixgbe_rxeof(struct ix_queue *);
751 753
752const struct sysctlnode *ixgbe_sysctl_instance(struct adapter *); 754const struct sysctlnode *ixgbe_sysctl_instance(struct adapter *);
753 755
754/* For NetBSD */ 756/* For NetBSD */
755void ixgbe_jcl_reinit(struct adapter *, bus_dma_tag_t, int, size_t); 757void ixgbe_jcl_reinit(struct adapter *, bus_dma_tag_t, struct rx_ring *,
 758 int, size_t);
756 759
757#include "ixgbe_bypass.h" 760#include "ixgbe_bypass.h"
758#include "ixgbe_fdir.h" 761#include "ixgbe_fdir.h"
759#include "ixgbe_rss.h" 762#include "ixgbe_rss.h"
760#include "ixgbe_netmap.h" 763#include "ixgbe_netmap.h"
761 764
762#endif /* _IXGBE_H_ */ 765#endif /* _IXGBE_H_ */

cvs diff -r1.7 -r1.8 src/sys/dev/pci/ixgbe/ixgbe_netbsd.c (expand / switch to unified diff)

--- src/sys/dev/pci/ixgbe/ixgbe_netbsd.c 2018/04/25 08:46:19 1.7
+++ src/sys/dev/pci/ixgbe/ixgbe_netbsd.c 2018/07/31 09:19:34 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ixgbe_netbsd.c,v 1.7 2018/04/25 08:46:19 msaitoh Exp $ */ 1/* $NetBSD: ixgbe_netbsd.c,v 1.8 2018/07/31 09:19:34 msaitoh Exp $ */
2/* 2/*
3 * Copyright (c) 2011 The NetBSD Foundation, Inc. 3 * Copyright (c) 2011 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to The NetBSD Foundation 6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Coyote Point Systems, Inc. 7 * by Coyote Point Systems, Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -152,71 +152,71 @@ ixgbe_newext(ixgbe_extmem_head_t *eh, bu @@ -152,71 +152,71 @@ ixgbe_newext(ixgbe_extmem_head_t *eh, bu
152 em->em_dmat = dmat; 152 em->em_dmat = dmat;
153 em->em_size = size; 153 em->em_size = size;
154 em->em_head = eh; 154 em->em_head = eh;
155 155
156 return em; 156 return em;
157post_dmamem_err: 157post_dmamem_err:
158 bus_dmamem_free(dmat, &em->em_seg, 1); 158 bus_dmamem_free(dmat, &em->em_seg, 1);
159post_zalloc_err: 159post_zalloc_err:
160 kmem_free(em, sizeof(*em)); 160 kmem_free(em, sizeof(*em));
161 return NULL; 161 return NULL;
162} 162}
163 163
164void 164void
165ixgbe_jcl_reinit(struct adapter *adapter, bus_dma_tag_t dmat, int nbuf, 165ixgbe_jcl_reinit(struct adapter *adapter, bus_dma_tag_t dmat,
166 size_t size) 166 struct rx_ring *rxr, int nbuf, size_t size)
167{ 167{
168 ixgbe_extmem_head_t *eh = &adapter->jcl_head; 168 ixgbe_extmem_head_t *eh = &rxr->jcl_head;
169 ixgbe_extmem_t *em; 169 ixgbe_extmem_t *em;
170 int i; 170 int i;
171 171
172 if (!eh->eh_initialized) { 172 if (!eh->eh_initialized) {
173 TAILQ_INIT(&eh->eh_freelist); 173 TAILQ_INIT(&eh->eh_freelist);
174 mutex_init(&eh->eh_mtx, MUTEX_DEFAULT, IPL_NET); 174 mutex_init(&eh->eh_mtx, MUTEX_DEFAULT, IPL_NET);
175 eh->eh_initialized = true; 175 eh->eh_initialized = true;
176 } 176 }
177 177
178 /* 178 /*
179 * Check previous parameters. If it's not required to reinit, just 179 * Check previous parameters. If it's not required to reinit, just
180 * return. 180 * return.
181 * 181 *
182 * Note that the num_rx_desc is currently fixed value. It's never 182 * Note that the num_rx_desc is currently fixed value. It's never
183 * changed after device is attached. 183 * changed after device is attached.
184 */ 184 */
185 if ((adapter->osdep.last_rx_mbuf_sz == adapter->rx_mbuf_sz) 185 if ((rxr->last_rx_mbuf_sz == rxr->mbuf_sz)
186 && (adapter->osdep.last_num_rx_desc == adapter->num_rx_desc)) 186 && (rxr->last_num_rx_desc == adapter->num_rx_desc))
187 return; 187 return;
188 188
189 /* Free all dmamem */ 189 /* Free all dmamem */
190 while ((em = ixgbe_getext(eh, 0)) != NULL) { 190 while ((em = ixgbe_getext(eh, 0)) != NULL) {
191 KASSERT(em->em_vaddr != NULL); 191 KASSERT(em->em_vaddr != NULL);
192 bus_dmamem_unmap(dmat, em->em_vaddr, em->em_size); 192 bus_dmamem_unmap(dmat, em->em_vaddr, em->em_size);
193 bus_dmamem_free(dmat, &em->em_seg, 1); 193 bus_dmamem_free(dmat, &em->em_seg, 1);
194 memset(em, 0, sizeof(*em)); 194 memset(em, 0, sizeof(*em));
195 kmem_free(em, sizeof(*em)); 195 kmem_free(em, sizeof(*em));
196 } 196 }
197 197
198 for (i = 0; i < nbuf; i++) { 198 for (i = 0; i < nbuf; i++) {
199 if ((em = ixgbe_newext(eh, dmat, size)) == NULL) { 199 if ((em = ixgbe_newext(eh, dmat, size)) == NULL) {
200 printf("%s: only %d of %d jumbo buffers allocated\n", 200 printf("%s: only %d of %d jumbo buffers allocated\n",
201 __func__, i, nbuf); 201 __func__, i, nbuf);
202 break; 202 break;
203 } 203 }
204 ixgbe_putext(em); 204 ixgbe_putext(em);
205 } 205 }
206 206
207 /* Keep current parameters */ 207 /* Keep current parameters */
208 adapter->osdep.last_rx_mbuf_sz = adapter->rx_mbuf_sz; 208 rxr->last_rx_mbuf_sz = adapter->rx_mbuf_sz;
209 adapter->osdep.last_num_rx_desc = adapter->num_rx_desc; 209 rxr->last_num_rx_desc = adapter->num_rx_desc;
210} 210}
211 211
212static void 212static void
213ixgbe_jcl_free(struct mbuf *m, void *buf, size_t size, void *arg) 213ixgbe_jcl_free(struct mbuf *m, void *buf, size_t size, void *arg)
214{ 214{
215 ixgbe_extmem_t *em = arg; 215 ixgbe_extmem_t *em = arg;
216 216
217 KASSERT(em->em_size == size); 217 KASSERT(em->em_size == size);
218 218
219 ixgbe_putext(em); 219 ixgbe_putext(em);
220 /* this is an abstraction violation, but it does not lead to a 220 /* this is an abstraction violation, but it does not lead to a
221 * double-free 221 * double-free
222 */ 222 */

cvs diff -r1.22 -r1.23 src/sys/dev/pci/ixgbe/ixgbe_osdep.h (expand / switch to unified diff)

--- src/sys/dev/pci/ixgbe/ixgbe_osdep.h 2018/04/25 08:46:19 1.22
+++ src/sys/dev/pci/ixgbe/ixgbe_osdep.h 2018/07/31 09:19:34 1.23
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ixgbe_osdep.h,v 1.22 2018/04/25 08:46:19 msaitoh Exp $ */ 1/* $NetBSD: ixgbe_osdep.h,v 1.23 2018/07/31 09:19:34 msaitoh Exp $ */
2 2
3/****************************************************************************** 3/******************************************************************************
4 SPDX-License-Identifier: BSD-3-Clause 4 SPDX-License-Identifier: BSD-3-Clause
5 5
6 Copyright (c) 2001-2017, Intel Corporation 6 Copyright (c) 2001-2017, Intel Corporation
7 All rights reserved. 7 All rights reserved.
8 8
9 Redistribution and use in source and binary forms, with or without 9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are met: 10 modification, are permitted provided that the following conditions are met:
11 11
12 1. Redistributions of source code must retain the above copyright notice, 12 1. Redistributions of source code must retain the above copyright notice,
13 this list of conditions and the following disclaimer. 13 this list of conditions and the following disclaimer.
14 14
@@ -198,27 +198,26 @@ ixgbe_bcopy(void *restrict _src, void *r @@ -198,27 +198,26 @@ ixgbe_bcopy(void *restrict _src, void *r
198 return (0); 198 return (0);
199} 199}
200 200
201struct ixgbe_osdep 201struct ixgbe_osdep
202{ 202{
203 struct ethercom ec; 203 struct ethercom ec;
204 pci_chipset_tag_t pc; 204 pci_chipset_tag_t pc;
205 pcitag_t tag; 205 pcitag_t tag;
206 bus_space_tag_t mem_bus_space_tag; 206 bus_space_tag_t mem_bus_space_tag;
207 bus_space_handle_t mem_bus_space_handle; 207 bus_space_handle_t mem_bus_space_handle;
208 bus_size_t mem_size; 208 bus_size_t mem_size;
209 bus_dma_tag_t dmat; 209 bus_dma_tag_t dmat;
210 u16 last_rx_mbuf_sz; 210 u16 last_rx_mbuf_sz;
211 u32 last_num_rx_desc; 
212 pci_intr_handle_t *intrs; 211 pci_intr_handle_t *intrs;
213 int nintrs; 212 int nintrs;
214 void *ihs[IXG_MAX_NINTR]; 213 void *ihs[IXG_MAX_NINTR];
215 bool attached; 214 bool attached;
216}; 215};
217 216
218/* These routines need struct ixgbe_hw declared */ 217/* These routines need struct ixgbe_hw declared */
219struct ixgbe_hw; 218struct ixgbe_hw;
220device_t ixgbe_dev_from_hw(struct ixgbe_hw *hw); 219device_t ixgbe_dev_from_hw(struct ixgbe_hw *hw);
221 220
222/* These routines are needed by the shared code */ 221/* These routines are needed by the shared code */
223extern u16 ixgbe_read_pci_cfg(struct ixgbe_hw *, u32); 222extern u16 ixgbe_read_pci_cfg(struct ixgbe_hw *, u32);
224#define IXGBE_READ_PCIE_WORD ixgbe_read_pci_cfg 223#define IXGBE_READ_PCIE_WORD ixgbe_read_pci_cfg