Deleted Added
full compact
if_msk.c (192725) if_msk.c (192726)
1/******************************************************************************
2 *
3 * Name : sky2.c
4 * Project: Gigabit Ethernet Driver for FreeBSD 5.x/6.x
5 * Version: $Revision: 1.23 $
6 * Date : $Date: 2005/12/22 09:04:11 $
7 * Purpose: Main driver source file
8 *

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

94
95/*
96 * Device driver for the Marvell Yukon II Ethernet controller.
97 * Due to lack of documentation, this driver is based on the code from
98 * sk(4) and Marvell's myk(4) driver for FreeBSD 5.x.
99 */
100
101#include <sys/cdefs.h>
1/******************************************************************************
2 *
3 * Name : sky2.c
4 * Project: Gigabit Ethernet Driver for FreeBSD 5.x/6.x
5 * Version: $Revision: 1.23 $
6 * Date : $Date: 2005/12/22 09:04:11 $
7 * Purpose: Main driver source file
8 *

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

94
95/*
96 * Device driver for the Marvell Yukon II Ethernet controller.
97 * Due to lack of documentation, this driver is based on the code from
98 * sk(4) and Marvell's myk(4) driver for FreeBSD 5.x.
99 */
100
101#include <sys/cdefs.h>
102__FBSDID("$FreeBSD: head/sys/dev/msk/if_msk.c 192725 2009-05-25 04:27:12Z yongari $");
102__FBSDID("$FreeBSD: head/sys/dev/msk/if_msk.c 192726 2009-05-25 06:09:18Z yongari $");
103
104#include <sys/param.h>
105#include <sys/systm.h>
106#include <sys/bus.h>
107#include <sys/endian.h>
108#include <sys/mbuf.h>
109#include <sys/malloc.h>
110#include <sys/kernel.h>

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

2394 uint32_t control, prod, si;
2395 uint16_t offset, tcp_offset, tso_mtu;
2396 int error, i, nseg, tso;
2397
2398 MSK_IF_LOCK_ASSERT(sc_if);
2399
2400 tcp_offset = offset = 0;
2401 m = *m_head;
103
104#include <sys/param.h>
105#include <sys/systm.h>
106#include <sys/bus.h>
107#include <sys/endian.h>
108#include <sys/mbuf.h>
109#include <sys/malloc.h>
110#include <sys/kernel.h>

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

2394 uint32_t control, prod, si;
2395 uint16_t offset, tcp_offset, tso_mtu;
2396 int error, i, nseg, tso;
2397
2398 MSK_IF_LOCK_ASSERT(sc_if);
2399
2400 tcp_offset = offset = 0;
2401 m = *m_head;
2402 if ((m->m_pkthdr.csum_flags & (MSK_CSUM_FEATURES | CSUM_TSO)) != 0) {
2402 if ((sc_if->msk_flags & MSK_FLAG_DESCV2) == 0 &&
2403 (m->m_pkthdr.csum_flags & (MSK_CSUM_FEATURES | CSUM_TSO)) != 0) {
2403 /*
2404 * Since mbuf has no protocol specific structure information
2405 * in it we have to inspect protocol information here to
2406 * setup TSO and checksum offload. I don't know why Marvell
2407 * made a such decision in chip design because other GigE
2408 * hardwares normally takes care of all these chores in
2409 * hardware. However, TSO performance of Yukon II is very
2410 * good such that it's worth to implement it.

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

2521 }
2522
2523 control = 0;
2524 tso = 0;
2525 tx_le = NULL;
2526
2527 /* Check TSO support. */
2528 if ((m->m_pkthdr.csum_flags & CSUM_TSO) != 0) {
2404 /*
2405 * Since mbuf has no protocol specific structure information
2406 * in it we have to inspect protocol information here to
2407 * setup TSO and checksum offload. I don't know why Marvell
2408 * made a such decision in chip design because other GigE
2409 * hardwares normally takes care of all these chores in
2410 * hardware. However, TSO performance of Yukon II is very
2411 * good such that it's worth to implement it.

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

2522 }
2523
2524 control = 0;
2525 tso = 0;
2526 tx_le = NULL;
2527
2528 /* Check TSO support. */
2529 if ((m->m_pkthdr.csum_flags & CSUM_TSO) != 0) {
2529 tso_mtu = offset + m->m_pkthdr.tso_segsz;
2530 if ((sc_if->msk_flags & MSK_FLAG_DESCV2) != 0)
2531 tso_mtu = m->m_pkthdr.tso_segsz;
2532 else
2533 tso_mtu = offset + m->m_pkthdr.tso_segsz;
2530 if (tso_mtu != sc_if->msk_cdata.msk_tso_mtu) {
2531 tx_le = &sc_if->msk_rdata.msk_tx_ring[prod];
2532 tx_le->msk_addr = htole32(tso_mtu);
2534 if (tso_mtu != sc_if->msk_cdata.msk_tso_mtu) {
2535 tx_le = &sc_if->msk_rdata.msk_tx_ring[prod];
2536 tx_le->msk_addr = htole32(tso_mtu);
2533 tx_le->msk_control = htole32(OP_LRGLEN | HW_OWNER);
2537 if ((sc_if->msk_flags & MSK_FLAG_DESCV2) != 0)
2538 tx_le->msk_control = htole32(OP_MSS | HW_OWNER);
2539 else
2540 tx_le->msk_control =
2541 htole32(OP_LRGLEN | HW_OWNER);
2534 sc_if->msk_cdata.msk_tx_cnt++;
2535 MSK_INC(prod, MSK_TX_RING_CNT);
2536 sc_if->msk_cdata.msk_tso_mtu = tso_mtu;
2537 }
2538 tso++;
2539 }
2540 /* Check if we have a VLAN tag to insert. */
2541 if ((m->m_flags & M_VLANTAG) != 0) {

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

2549 } else {
2550 tx_le->msk_control |= htole32(OP_VLAN |
2551 htons(m->m_pkthdr.ether_vtag));
2552 }
2553 control |= INS_VLAN;
2554 }
2555 /* Check if we have to handle checksum offload. */
2556 if (tso == 0 && (m->m_pkthdr.csum_flags & MSK_CSUM_FEATURES) != 0) {
2542 sc_if->msk_cdata.msk_tx_cnt++;
2543 MSK_INC(prod, MSK_TX_RING_CNT);
2544 sc_if->msk_cdata.msk_tso_mtu = tso_mtu;
2545 }
2546 tso++;
2547 }
2548 /* Check if we have a VLAN tag to insert. */
2549 if ((m->m_flags & M_VLANTAG) != 0) {

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

2557 } else {
2558 tx_le->msk_control |= htole32(OP_VLAN |
2559 htons(m->m_pkthdr.ether_vtag));
2560 }
2561 control |= INS_VLAN;
2562 }
2563 /* Check if we have to handle checksum offload. */
2564 if (tso == 0 && (m->m_pkthdr.csum_flags & MSK_CSUM_FEATURES) != 0) {
2557 tx_le = &sc_if->msk_rdata.msk_tx_ring[prod];
2558 tx_le->msk_addr = htole32(((tcp_offset + m->m_pkthdr.csum_data)
2559 & 0xffff) | ((uint32_t)tcp_offset << 16));
2560 tx_le->msk_control = htole32(1 << 16 | (OP_TCPLISW | HW_OWNER));
2561 control = CALSUM | WR_SUM | INIT_SUM | LOCK_SUM;
2562 if ((m->m_pkthdr.csum_flags & CSUM_UDP) != 0)
2563 control |= UDPTCP;
2564 sc_if->msk_cdata.msk_tx_cnt++;
2565 MSK_INC(prod, MSK_TX_RING_CNT);
2565 if ((sc_if->msk_flags & MSK_FLAG_DESCV2) != 0)
2566 control |= CALSUM;
2567 else {
2568 tx_le = &sc_if->msk_rdata.msk_tx_ring[prod];
2569 tx_le->msk_addr = htole32(((tcp_offset +
2570 m->m_pkthdr.csum_data) & 0xffff) |
2571 ((uint32_t)tcp_offset << 16));
2572 tx_le->msk_control = htole32(1 << 16 |
2573 (OP_TCPLISW | HW_OWNER));
2574 control = CALSUM | WR_SUM | INIT_SUM | LOCK_SUM;
2575 if ((m->m_pkthdr.csum_flags & CSUM_UDP) != 0)
2576 control |= UDPTCP;
2577 sc_if->msk_cdata.msk_tx_cnt++;
2578 MSK_INC(prod, MSK_TX_RING_CNT);
2579 }
2566 }
2567
2568 si = prod;
2569 tx_le = &sc_if->msk_rdata.msk_tx_ring[prod];
2570 tx_le->msk_addr = htole32(MSK_ADDR_LO(txsegs[0].ds_addr));
2571 if (tso == 0)
2572 tx_le->msk_control = htole32(txsegs[0].ds_len | control |
2573 OP_PACKET);

--- 1661 unchanged lines hidden ---
2580 }
2581
2582 si = prod;
2583 tx_le = &sc_if->msk_rdata.msk_tx_ring[prod];
2584 tx_le->msk_addr = htole32(MSK_ADDR_LO(txsegs[0].ds_addr));
2585 if (tso == 0)
2586 tx_le->msk_control = htole32(txsegs[0].ds_len | control |
2587 OP_PACKET);

--- 1661 unchanged lines hidden ---