Deleted Added
full compact
ethernet-rx.c (213156) ethernet-rx.c (215974)
1/*************************************************************************
2Copyright (c) 2003-2007 Cavium Networks (support@cavium.com). All rights
3reserved.
4
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are
8met:

--- 14 unchanged lines hidden (view full) ---

23This Software, including technical data, may be subject to U.S. export control laws, including the U.S. Export Administration Act and its associated regulations, and may be subject to export or import regulations in other countries.
24
25TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
26AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
27
28*************************************************************************/
29
30#include <sys/cdefs.h>
1/*************************************************************************
2Copyright (c) 2003-2007 Cavium Networks (support@cavium.com). All rights
3reserved.
4
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are
8met:

--- 14 unchanged lines hidden (view full) ---

23This Software, including technical data, may be subject to U.S. export control laws, including the U.S. Export Administration Act and its associated regulations, and may be subject to export or import regulations in other countries.
24
25TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
26AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
27
28*************************************************************************/
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/mips/cavium/octe/ethernet-rx.c 213156 2010-09-25 04:39:12Z jmallett $");
31__FBSDID("$FreeBSD: head/sys/mips/cavium/octe/ethernet-rx.c 215974 2010-11-28 05:57:24Z jmallett $");
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/bus.h>
36#include <sys/endian.h>
37#include <sys/kernel.h>
38#include <sys/mbuf.h>
39#include <sys/socket.h>

--- 30 unchanged lines hidden (view full) ---

70 cvmx_write_csr(CVMX_POW_WQ_INT, 1<<pow_receive_group);
71 else
72 cvmx_write_csr(CVMX_POW_WQ_INT, 0x10001<<pow_receive_group);
73 taskqueue_enqueue(cvm_oct_taskq, &cvm_oct_task);
74 return FILTER_HANDLED;
75}
76
77
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/bus.h>
36#include <sys/endian.h>
37#include <sys/kernel.h>
38#include <sys/mbuf.h>
39#include <sys/socket.h>

--- 30 unchanged lines hidden (view full) ---

70 cvmx_write_csr(CVMX_POW_WQ_INT, 1<<pow_receive_group);
71 else
72 cvmx_write_csr(CVMX_POW_WQ_INT, 0x10001<<pow_receive_group);
73 taskqueue_enqueue(cvm_oct_taskq, &cvm_oct_task);
74 return FILTER_HANDLED;
75}
76
77
78#ifdef CONFIG_NET_POLL_CONTROLLER
79/**
78/**
80 * This is called when the kernel needs to manually poll the
81 * device. For Octeon, this is simply calling the interrupt
82 * handler. We actually poll all the devices, not just the
83 * one supplied.
84 *
85 * @param dev Device to poll. Unused
86 */
87void cvm_oct_poll_controller(struct ifnet *ifp)
88{
89 taskqueue_enqueue(cvm_oct_taskq, &cvm_oct_task);
90}
91#endif
92
93/**
94 * This is called on receive errors, and determines if the packet
95 * can be dropped early-on in cvm_oct_tasklet_rx().
96 *
97 * @param work Work queue entry pointing to the packet.
98 * @return Non-zero if the packet can be dropped, zero otherwise.
99 */
100static inline int cvm_oct_check_rcv_error(cvmx_wqe_t *work)
101{

--- 119 unchanged lines hidden (view full) ---

221 if ((INTERRUPT_LIMIT == 0) || (rx_count < MAX_RX_PACKETS))
222 cvmx_pow_work_request_async_nocheck(CVMX_SCR_SCRATCH, CVMX_POW_NO_WAIT);
223 else {
224 cvmx_scratch_write64(CVMX_SCR_SCRATCH, 0x8000000000000000ull);
225 cvmx_pow_tag_sw_null_nocheck();
226 }
227 }
228
79 * This is called on receive errors, and determines if the packet
80 * can be dropped early-on in cvm_oct_tasklet_rx().
81 *
82 * @param work Work queue entry pointing to the packet.
83 * @return Non-zero if the packet can be dropped, zero otherwise.
84 */
85static inline int cvm_oct_check_rcv_error(cvmx_wqe_t *work)
86{

--- 119 unchanged lines hidden (view full) ---

206 if ((INTERRUPT_LIMIT == 0) || (rx_count < MAX_RX_PACKETS))
207 cvmx_pow_work_request_async_nocheck(CVMX_SCR_SCRATCH, CVMX_POW_NO_WAIT);
208 else {
209 cvmx_scratch_write64(CVMX_SCR_SCRATCH, 0x8000000000000000ull);
210 cvmx_pow_tag_sw_null_nocheck();
211 }
212 }
213
229 mbuf_in_hw = USE_MBUFS_IN_HW && work->word2.s.bufs == 1;
214 mbuf_in_hw = work->word2.s.bufs == 1;
230 if ((mbuf_in_hw)) {
231 m = *(struct mbuf **)(cvm_oct_get_buffer_ptr(work->packet_ptr) - sizeof(void *));
232 CVMX_PREFETCH(m, offsetof(struct mbuf, m_data));
233 CVMX_PREFETCH(m, offsetof(struct mbuf, m_pkthdr));
234 }
235 CVMX_PREFETCH(cvm_oct_device[work->ipprt], 0);
236 //CVMX_PREFETCH(m, 0);
237

--- 113 unchanged lines hidden (view full) ---

351 /* Drop any packet received for a device that
352 doesn't exist */
353 DEBUGPRINT("Port %d not controlled by Linux, packet dropped\n", work->ipprt);
354 m_freem(m);
355 }
356
357 /* Check to see if the mbuf and work share
358 the same packet buffer */
215 if ((mbuf_in_hw)) {
216 m = *(struct mbuf **)(cvm_oct_get_buffer_ptr(work->packet_ptr) - sizeof(void *));
217 CVMX_PREFETCH(m, offsetof(struct mbuf, m_data));
218 CVMX_PREFETCH(m, offsetof(struct mbuf, m_pkthdr));
219 }
220 CVMX_PREFETCH(cvm_oct_device[work->ipprt], 0);
221 //CVMX_PREFETCH(m, 0);
222

--- 113 unchanged lines hidden (view full) ---

336 /* Drop any packet received for a device that
337 doesn't exist */
338 DEBUGPRINT("Port %d not controlled by Linux, packet dropped\n", work->ipprt);
339 m_freem(m);
340 }
341
342 /* Check to see if the mbuf and work share
343 the same packet buffer */
359 if (USE_MBUFS_IN_HW && (packet_not_copied)) {
344 if ((packet_not_copied)) {
360 /* This buffer needs to be replaced, increment
361 the number of buffers we need to free by one */
362 cvmx_fau_atomic_add32(
363 FAU_NUM_PACKET_BUFFERS_TO_FREE, 1);
364
365 cvmx_fpa_free(work, CVMX_FPA_WQE_POOL,
366 DONT_WRITEBACK(1));
367 } else
368 cvm_oct_free_work(work);
369 }
370
371 /* Restore the original POW group mask */
372 cvmx_write_csr(CVMX_POW_PP_GRP_MSKX(coreid), old_group_mask);
373 if (USE_ASYNC_IOBDMA) {
374 /* Restore the scratch area */
375 cvmx_scratch_write64(CVMX_SCR_SCRATCH, old_scratch);
376 }
377
345 /* This buffer needs to be replaced, increment
346 the number of buffers we need to free by one */
347 cvmx_fau_atomic_add32(
348 FAU_NUM_PACKET_BUFFERS_TO_FREE, 1);
349
350 cvmx_fpa_free(work, CVMX_FPA_WQE_POOL,
351 DONT_WRITEBACK(1));
352 } else
353 cvm_oct_free_work(work);
354 }
355
356 /* Restore the original POW group mask */
357 cvmx_write_csr(CVMX_POW_PP_GRP_MSKX(coreid), old_group_mask);
358 if (USE_ASYNC_IOBDMA) {
359 /* Restore the scratch area */
360 cvmx_scratch_write64(CVMX_SCR_SCRATCH, old_scratch);
361 }
362
378 if (USE_MBUFS_IN_HW) {
379 /* Refill the packet buffer pool */
380 number_to_free =
381 cvmx_fau_fetch_and_add32(FAU_NUM_PACKET_BUFFERS_TO_FREE, 0);
363 /* Refill the packet buffer pool */
364 number_to_free =
365 cvmx_fau_fetch_and_add32(FAU_NUM_PACKET_BUFFERS_TO_FREE, 0);
382
366
383 if (number_to_free > 0) {
367 if (number_to_free > 0) {
368 cvmx_fau_atomic_add32(FAU_NUM_PACKET_BUFFERS_TO_FREE,
369 -number_to_free);
370 num_freed =
371 cvm_oct_mem_fill_fpa(CVMX_FPA_PACKET_POOL,
372 CVMX_FPA_PACKET_POOL_SIZE,
373 number_to_free);
374 if (num_freed != number_to_free) {
384 cvmx_fau_atomic_add32(FAU_NUM_PACKET_BUFFERS_TO_FREE,
375 cvmx_fau_atomic_add32(FAU_NUM_PACKET_BUFFERS_TO_FREE,
385 -number_to_free);
386 num_freed =
387 cvm_oct_mem_fill_fpa(CVMX_FPA_PACKET_POOL,
388 CVMX_FPA_PACKET_POOL_SIZE,
389 number_to_free);
390 if (num_freed != number_to_free) {
391 cvmx_fau_atomic_add32(FAU_NUM_PACKET_BUFFERS_TO_FREE,
392 number_to_free - num_freed);
393 }
376 number_to_free - num_freed);
394 }
395 }
396 sched_unpin();
397}
398
399
400
401void cvm_oct_rx_initialize(void)

--- 15 unchanged lines hidden ---
377 }
378 }
379 sched_unpin();
380}
381
382
383
384void cvm_oct_rx_initialize(void)

--- 15 unchanged lines hidden ---