summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Stezenbach <devnull@localhost>2004-04-14 16:57:13 +0000
committerJohannes Stezenbach <devnull@localhost>2004-04-14 16:57:13 +0000
commit98bd04299fa94ff61e8e2e1e3b8bee3cd924bb4c (patch)
treeb0dd3b0c345849a5332882789e14ca1d1b41e8b1
parent931e006a04fe885600f7af35d03a16029cbecfbf (diff)
downloadmediapointer-dvb-s2-98bd04299fa94ff61e8e2e1e3b8bee3cd924bb4c.tar.gz
mediapointer-dvb-s2-98bd04299fa94ff61e8e2e1e3b8bee3cd924bb4c.tar.bz2
formatting and codingstyle fixes
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_net.c464
1 files changed, 253 insertions, 211 deletions
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_net.c b/linux/drivers/media/dvb/dvb-core/dvb_net.c
index 991ff4138..a108db354 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/linux/drivers/media/dvb/dvb-core/dvb_net.c
@@ -1,10 +1,10 @@
-/*
+/*
* dvb_net.c
*
* Copyright (C) 2001 Convergence integrated media GmbH
* Ralph Metzler <ralph@convergence.de>
* Copyright (C) 2002 Ralph Metzler <rjkm@metzlerbros.de>
- *
+ *
* ULE Decapsulation code:
* Copyright (C) 2003 gcs - Global Communication & Services GmbH.
* and Institute for Computer Sciences
@@ -18,19 +18,16 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
- *
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- *
*/
#include <linux/kernel.h>
@@ -114,21 +111,23 @@ struct dvb_net_priv {
#define RX_MODE_PROMISC 3
struct work_struct set_multicast_list_wq;
struct work_struct restart_net_feed_wq;
- unsigned char feedtype;
- int need_pusi;
- unsigned char tscc; // TS continuity counter after sync.
- struct sk_buff *ule_skb;
- unsigned short ule_sndu_len;
- unsigned short ule_sndu_type;
- unsigned char ule_sndu_type_1;
- unsigned char ule_dbit; // whether the DestMAC address present bit is set or not.
- unsigned char ule_ethhdr_complete; // whether we have completed the Ethernet header for the current ULE SNDU.
- int ule_sndu_remain;
+ unsigned char feedtype;
+ int need_pusi;
+ unsigned char tscc; /* TS continuity counter after sync. */
+ struct sk_buff *ule_skb;
+ unsigned short ule_sndu_len;
+ unsigned short ule_sndu_type;
+ unsigned char ule_sndu_type_1;
+ unsigned char ule_dbit; /* whether the DestMAC address present
+ * bit is set or not. */
+ unsigned char ule_ethhdr_complete; /* whether we have completed the Ethernet
+ * header for the current ULE SNDU. */
+ int ule_sndu_remain;
};
/**
- * Determine the packet's protocol ID. The rule here is that we
+ * Determine the packet's protocol ID. The rule here is that we
* assume 802.3 if the type field is short enough to be a length.
* This is normal practice and works for any 'now in use' protocol.
*
@@ -140,23 +139,23 @@ static unsigned short dvb_net_eth_type_trans(struct sk_buff *skb,
{
struct ethhdr *eth;
unsigned char *rawp;
-
+
skb->mac.raw=skb->data;
skb_pull(skb,dev->hard_header_len);
eth= skb->mac.ethernet;
-
+
if (*eth->h_dest & 1) {
if(memcmp(eth->h_dest,dev->broadcast, ETH_ALEN)==0)
skb->pkt_type=PACKET_BROADCAST;
else
skb->pkt_type=PACKET_MULTICAST;
}
-
+
if (ntohs(eth->h_proto) >= 1536)
return eth->h_proto;
-
+
rawp = skb->data;
-
+
/**
* This is a magic hack to spot IPX packets. Older Novell breaks
* the protocol design and runs IPX over 802.3 without an 802.2 LLC
@@ -165,7 +164,7 @@ static unsigned short dvb_net_eth_type_trans(struct sk_buff *skb,
*/
if (*(unsigned short *)rawp == 0xFFFF)
return htons(ETH_P_802_3);
-
+
/**
* Real 802.2 LLC
*/
@@ -209,33 +208,37 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
return;
}
- for (ts = (char *)buf, ts_end = (char *)buf + buf_len; ts < ts_end;) {
+ for (ts = (char *)buf, ts_end = (char *)buf + buf_len; ts < ts_end; ) {
if (emergency_count++ > 200) {
- // Huh??
- hexdump( ts, TS_SZ );
- printk( KERN_WARNING "*** LOOP ALERT! ts %p ts_remain %u how_much %u, ule_skb %p, ule_len %u, ule_remain %u\n",
- ts, ts_remain, how_much, priv->ule_skb, priv->ule_sndu_len, priv->ule_sndu_remain );
+ /* Huh?? */
+ hexdump(ts, TS_SZ);
+ printk(KERN_WARNING "*** LOOP ALERT! ts %p ts_remain %u "
+ "how_much %u, ule_skb %p, ule_len %u, ule_remain %u\n",
+ ts, ts_remain, how_much, priv->ule_skb,
+ priv->ule_sndu_len, priv->ule_sndu_remain);
break;
}
if (new_ts) {
if ((ts[0] != TS_SYNC) || (ts[1] & TS_TEI)) {
- printk( KERN_WARNING "Invalid TS cell: SYNC %#x, TEI %u.\n", ts[0], ts[1] & TS_TEI >> 7 );
+ printk(KERN_WARNING "Invalid TS cell: SYNC %#x, TEI %u.\n",
+ ts[0], ts[1] & TS_TEI >> 7);
continue;
}
ts_remain = 184;
from_where = ts + 4;
}
- // Synchronize on PUSI, if required.
+ /* Synchronize on PUSI, if required. */
if (priv->need_pusi) {
if (ts[1] & TS_PUSI) {
- // Find beginning of first ULE SNDU in current TS cell.
- // priv->need_pusi = 0;
+ /* Find beginning of first ULE SNDU in current TS cell.
+ * priv->need_pusi = 0; */
priv->tscc = ts[3] & 0x0F;
- // There is a pointer field here.
+ /* There is a pointer field here. */
if (ts[4] > ts_remain) {
- printk( KERN_ERR "Invalid ULE packet (pointer field %d)\n", ts[4] );
+ printk(KERN_ERR "Invalid ULE packet "
+ "(pointer field %d)\n", ts[4]);
continue;
}
from_where = &ts[5] + ts[4];
@@ -247,58 +250,69 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
}
}
- // Check continuity counter.
+ /* Check continuity counter. */
if (new_ts) {
if ((ts[3] & 0x0F) == priv->tscc)
priv->tscc = (priv->tscc + 1) & 0x0F;
else {
- // TS discontinuity handling:
+ /* TS discontinuity handling: */
if (priv->ule_skb) {
dev_kfree_skb( priv->ule_skb );
- // Prepare for next SNDU.
- reset_ule( priv );
+ /* Prepare for next SNDU. */
+ reset_ule(priv);
((struct dvb_net_priv *) dev->priv)->stats.rx_errors++;
((struct dvb_net_priv *) dev->priv)->stats.rx_frame_errors++;
}
- // skip to next PUSI.
- printk( KERN_WARNING "TS discontinuity: got %#x, exptected %#x.\n", ts[3] & 0x0F, priv->tscc );
+ /* skip to next PUSI. */
+ printk(KERN_WARNING "TS discontinuity: got %#x, "
+ "exptected %#x.\n", ts[3] & 0x0F, priv->tscc);
priv->need_pusi = 1;
continue;
}
- // If we still have an incomplete payload, but PUSI is set, some TS cells are missing.
- // This is only possible here, if we missed exactly 16 TS cells (continuity counter).
+ /* If we still have an incomplete payload, but PUSI is
+ * set, some TS cells are missing.
+ * This is only possible here, if we missed exactly 16 TS
+ * cells (continuity counter). */
if (ts[1] & TS_PUSI) {
if (! priv->need_pusi) {
- // printk( KERN_WARNING "Skipping pointer field %u.\n", *from_where );
+ /* printk(KERN_WARNING "Skipping pointer field %u.\n", *from_where); */
if (*from_where > 181) {
- printk( KERN_WARNING "*** Invalid pointer field: %u. Current TS cell follows:\n", *from_where );
+ printk(KERN_WARNING "*** Invalid pointer "
+ "field: %u. Current TS cell "
+ "follows:\n", *from_where);
hexdump( ts, TS_SZ );
- printk( KERN_WARNING "-------------------------------------------------------------\n" );
+ printk(KERN_WARNING "-------------------\n");
}
- // Skip pointer field (we're processing a packed payload).
+ /* Skip pointer field (we're processing a
+ * packed payload). */
from_where += 1;
ts_remain -= 1;
- } else
+ } else
priv->need_pusi = 0;
if (priv->ule_sndu_remain > 183) {
((struct dvb_net_priv *) dev->priv)->stats.rx_errors++;
((struct dvb_net_priv *) dev->priv)->stats.rx_length_errors++;
- printk( KERN_WARNING "Expected %d more SNDU bytes, but got PUSI. Flushing incomplete payload.\n", priv->ule_sndu_remain );
- dev_kfree_skb( priv->ule_skb );
- // Prepare for next SNDU.
- reset_ule( priv );
+ printk(KERN_WARNING "Expected %d more SNDU bytes, but "
+ "got PUSI. Flushing incomplete payload.\n",
+ priv->ule_sndu_remain);
+ dev_kfree_skb(priv->ule_skb);
+ /* Prepare for next SNDU. */
+ reset_ule(priv);
}
}
}
- // Check if new payload needs to be started.
+ /* Check if new payload needs to be started. */
if (priv->ule_skb == NULL) {
- // Start a new payload w/ skb.
- // Find ULE header. It is only guaranteed that the length field (2 bytes) is contained in the current TS.
- // Check ts_remain has to be >= 2 here.
+ /* Start a new payload w/ skb.
+ * Find ULE header. It is only guaranteed that the
+ * length field (2 bytes) is contained in the current
+ * TS.
+ * Check ts_remain has to be >= 2 here. */
if (ts_remain < 2) {
- printk( KERN_WARNING "Invalid payload packing: only %d bytes left in TS. Resyncing.\n", ts_remain );
+ printk(KERN_WARNING "Invalid payload packing: only %d "
+ "bytes left in TS. Resyncing.\n", ts_remain);
priv->ule_sndu_len = 0;
priv->need_pusi = 1;
continue;
@@ -307,24 +321,26 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
if (! priv->ule_sndu_len) {
priv->ule_sndu_len = from_where[0] << 8 | from_where[1];
if (priv->ule_sndu_len & 0x8000) {
- // D-Bit is set: no dest mac present.
+ /* D-Bit is set: no dest mac present. */
priv->ule_sndu_len &= 0x7FFF;
priv->ule_dbit = 1;
} else
priv->ule_dbit = 0;
- // printk( KERN_WARNING "ULE D-Bit: %d, SNDU len %u.\n", priv->ule_dbit, priv->ule_sndu_len );
+ /* printk(KERN_WARNING "ULE D-Bit: %d, SNDU len %u.\n",
+ priv->ule_dbit, priv->ule_sndu_len); */
if (priv->ule_sndu_len > 32763) {
- printk( KERN_WARNING "Invalid ULE SNDU length %u. Resyncing.\n", priv->ule_sndu_len );
- hexdump( ts, TS_SZ );
+ printk(KERN_WARNING "Invalid ULE SNDU length %u. "
+ "Resyncing.\n", priv->ule_sndu_len);
+ hexdump(ts, TS_SZ);
priv->ule_sndu_len = 0;
priv->need_pusi = 1;
new_ts = 1;
ts += TS_SZ;
continue;
}
- ts_remain -= 2; // consume the 2 bytes SNDU length.
+ ts_remain -= 2; /* consume the 2 bytes SNDU length. */
from_where += 2;
}
@@ -338,37 +354,39 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
switch (ts_remain) {
case 1:
priv->ule_sndu_type = from_where[0] << 8;
- priv->ule_sndu_type_1 = 1; // first byte of ule_type is set.
- // ts_remain -= 1; from_where += 1; here not necessary, because we continue.
+ priv->ule_sndu_type_1 = 1; /* first byte of ule_type is set. */
+ /* ts_remain -= 1; from_where += 1;
+ * here not necessary, because we continue. */
case 0:
- new_ts = 1;
+ new_ts = 1;
ts += TS_SZ;
continue;
- default: // complete ULE header is present in current TS.
- // Extract ULE type field.
+ default: /* complete ULE header is present in current TS. */
+ /* Extract ULE type field. */
if (priv->ule_sndu_type_1) {
priv->ule_sndu_type |= from_where[0];
- from_where += 1; // points to payload start.
+ from_where += 1; /* points to payload start. */
ts_remain -= 1;
} else {
- // Complete type is present in new TS.
+ /* Complete type is present in new TS. */
priv->ule_sndu_type = from_where[0] << 8 | from_where[1];
- from_where += 2; // points to payload start.
+ from_where += 2; /* points to payload start. */
ts_remain -= 2;
}
break;
}
if (priv->ule_sndu_type == ULE_TEST) {
- // Test SNDU, discarded by the receiver.
- printk( KERN_WARNING "Discarding ULE Test SNDU (%d bytes). Resyncing.\n", priv->ule_sndu_len );
+ /* Test SNDU, discarded by the receiver. */
+ printk(KERN_WARNING "Discarding ULE Test SNDU (%d bytes). "
+ "Resyncing.\n", priv->ule_sndu_len);
priv->ule_sndu_len = 0;
priv->need_pusi = 1;
continue;
}
- skblen = priv->ule_sndu_len; // Including CRC32
+ skblen = priv->ule_sndu_len; /* Including CRC32 */
if (priv->ule_sndu_type != ULE_BRIDGED) {
skblen += ETH_HLEN;
#if 1
@@ -376,9 +394,10 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
skblen -= ETH_ALEN;
#endif
}
- priv->ule_skb = dev_alloc_skb( skblen );
+ priv->ule_skb = dev_alloc_skb(skblen);
if (priv->ule_skb == NULL) {
- printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name);
+ printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n",
+ dev->name);
((struct dvb_net_priv *)dev->priv)->stats.rx_dropped++;
return;
}
@@ -396,110 +415,133 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
// Dest MAC address could be split across two TS cells.
// FIXME: implement.
- printk( KERN_WARNING "%s: got destination MAC address.\n", dev->name );
+ printk( KERN_WARNING "%s: got destination MAC "
+ "address.\n", dev->name );
memcpy( ethh->h_dest, eth_dest_addr, ETH_ALEN );
}
- ethh->h_proto = htons( priv->ule_sndu_type == ULE_LLC ? priv->ule_sndu_len : priv->ule_sndu_type );
+ ethh->h_proto = htons(priv->ule_sndu_type == ULE_LLC ?
+ priv->ule_sndu_len : priv->ule_sndu_type);
}
#endif
- priv->ule_sndu_remain = priv->ule_sndu_len; // this includes the CRC32 _and_ dest mac, if !dbit!
+ /* this includes the CRC32 _and_ dest mac, if !dbit! */
+ priv->ule_sndu_remain = priv->ule_sndu_len;
priv->ule_skb->dev = dev;
}
- // Copy data into our current skb.
- how_much = min( priv->ule_sndu_remain, (int)ts_remain );
- if ((priv->ule_ethhdr_complete < ETH_ALEN) && (priv->ule_sndu_type != ULE_BRIDGED)) {
+ /* Copy data into our current skb. */
+ how_much = min(priv->ule_sndu_remain, (int)ts_remain);
+ if ((priv->ule_ethhdr_complete < ETH_ALEN) &&
+ (priv->ule_sndu_type != ULE_BRIDGED)) {
ethh = (struct ethhdr *)priv->ule_skb->data;
if (! priv->ule_dbit) {
if (how_much >= (ETH_ALEN - priv->ule_ethhdr_complete)) {
- // copy dest mac address.
- memcpy( skb_put( priv->ule_skb, (ETH_ALEN - priv->ule_ethhdr_complete) ), from_where, (ETH_ALEN - priv->ule_ethhdr_complete) );
- memset( ethh->h_source, 0x00, ETH_ALEN );
- ethh->h_proto = htons( priv->ule_sndu_type == ULE_LLC ? priv->ule_sndu_len : priv->ule_sndu_type );
- (void)skb_put( priv->ule_skb, ETH_ALEN + 2 );
+ /* copy dest mac address. */
+ memcpy(skb_put(priv->ule_skb,
+ (ETH_ALEN - priv->ule_ethhdr_complete)),
+ from_where,
+ (ETH_ALEN - priv->ule_ethhdr_complete));
+ memset(ethh->h_source, 0x00, ETH_ALEN);
+ ethh->h_proto = htons(priv->ule_sndu_type == ULE_LLC ?
+ priv->ule_sndu_len :
+ priv->ule_sndu_type);
+ skb_put(priv->ule_skb, ETH_ALEN + 2);
how_much -= (ETH_ALEN - priv->ule_ethhdr_complete);
- priv->ule_sndu_remain -= (ETH_ALEN - priv->ule_ethhdr_complete);
+ priv->ule_sndu_remain -= (ETH_ALEN -
+ priv->ule_ethhdr_complete);
ts_remain -= (ETH_ALEN - priv->ule_ethhdr_complete);
from_where += (ETH_ALEN - priv->ule_ethhdr_complete);
priv->ule_ethhdr_complete = ETH_ALEN;
}
} else {
- // Generate whole Ethernet header.
- memcpy( ethh->h_dest, eth_dest_addr, ETH_ALEN );
- memset( ethh->h_source, 0x00, ETH_ALEN );
- ethh->h_proto = htons( priv->ule_sndu_type == ULE_LLC ? priv->ule_sndu_len : priv->ule_sndu_type );
- (void)skb_put( priv->ule_skb, ETH_HLEN );
+ /* Generate whole Ethernet header. */
+ memcpy(ethh->h_dest, eth_dest_addr, ETH_ALEN);
+ memset(ethh->h_source, 0x00, ETH_ALEN);
+ ethh->h_proto = htons(priv->ule_sndu_type == ULE_LLC ?
+ priv->ule_sndu_len : priv->ule_sndu_type);
+ skb_put(priv->ule_skb, ETH_HLEN);
priv->ule_ethhdr_complete = ETH_ALEN;
}
}
- // printk( KERN_WARNING "Copying %u bytes, ule_sndu_remain = %u, ule_sndu_len = %u.\n", how_much, priv->ule_sndu_remain, priv->ule_sndu_len );
- memcpy( skb_put( priv->ule_skb, how_much ), from_where, how_much );
+ /* printk(KERN_WARNING "Copying %u bytes, ule_sndu_remain = %u, "
+ "ule_sndu_len = %u.\n", how_much, priv->ule_sndu_remain,
+ priv->ule_sndu_len); */
+ memcpy(skb_put(priv->ule_skb, how_much), from_where, how_much);
priv->ule_sndu_remain -= how_much;
ts_remain -= how_much;
from_where += how_much;
- //
- if ((priv->ule_ethhdr_complete < ETH_ALEN) && (priv->ule_sndu_type != ULE_BRIDGED)) {
+ if ((priv->ule_ethhdr_complete < ETH_ALEN) &&
+ (priv->ule_sndu_type != ULE_BRIDGED)) {
priv->ule_ethhdr_complete += how_much;
}
- // Check for complete payload.
+ /* Check for complete payload. */
if (priv->ule_sndu_remain <= 0) {
- // Check CRC32, we've got it in our skb already.
- unsigned short ulen = htons( priv->ule_sndu_len );
- unsigned short utype = htons( priv->ule_sndu_type );
- struct iovec iov[4] = { { &ulen, sizeof ulen },
- { &utype, sizeof utype },
- { NULL, 0 },
- { priv->ule_skb->data + ETH_HLEN, priv->ule_skb->len - ETH_HLEN - 4 } };
+ /* Check CRC32, we've got it in our skb already. */
+ unsigned short ulen = htons(priv->ule_sndu_len);
+ unsigned short utype = htons(priv->ule_sndu_type);
+ struct iovec iov[4] = {
+ { &ulen, sizeof ulen },
+ { &utype, sizeof utype },
+ { NULL, 0 },
+ { priv->ule_skb->data + ETH_HLEN,
+ priv->ule_skb->len - ETH_HLEN - 4 }
+ };
unsigned long ule_crc = ~0L, expected_crc;
if (priv->ule_dbit) {
- ulen |= 0x0080; // Set D-bit for CRC32 verification, if it was set originally.
+ /* Set D-bit for CRC32 verification,
+ * if it was set originally. */
+ ulen |= 0x0080;
} else {
iov[2].iov_base = priv->ule_skb->data;
iov[2].iov_len = ETH_ALEN;
}
- ule_crc = iov_crc32( ule_crc, iov, 4 );
- expected_crc = *((u8 *)priv->ule_skb->tail - 4) << 24 | *((u8 *)priv->ule_skb->tail - 3) << 16 |
- *((u8 *)priv->ule_skb->tail - 2) << 8 | *((u8 *)priv->ule_skb->tail - 1);
+ ule_crc = iov_crc32(ule_crc, iov, 4);
+ expected_crc = *((u8 *)priv->ule_skb->tail - 4) << 24 |
+ *((u8 *)priv->ule_skb->tail - 3) << 16 |
+ *((u8 *)priv->ule_skb->tail - 2) << 8 |
+ *((u8 *)priv->ule_skb->tail - 1);
if (ule_crc != expected_crc) {
- printk( KERN_WARNING "CRC32 check %s: %#lx / %#lx.\n",
- ule_crc != expected_crc ? "FAILED" : "OK", ule_crc, expected_crc );
- hexdump( priv->ule_skb->data + ETH_HLEN, priv->ule_skb->len - ETH_HLEN );
+ printk(KERN_WARNING "CRC32 check %s: %#lx / %#lx.\n",
+ ule_crc != expected_crc ? "FAILED" : "OK",
+ ule_crc, expected_crc);
+ hexdump(priv->ule_skb->data + ETH_HLEN,
+ priv->ule_skb->len - ETH_HLEN);
((struct dvb_net_priv *) dev->priv)->stats.rx_errors++;
((struct dvb_net_priv *) dev->priv)->stats.rx_crc_errors++;
- dev_kfree_skb( priv->ule_skb );
+ dev_kfree_skb(priv->ule_skb);
} else {
- // CRC32 was OK. Remove it from skb.
+ /* CRC32 was OK. Remove it from skb. */
priv->ule_skb->tail -= 4;
priv->ule_skb->len -= 4;
- // Stuff into kernel's protocol stack.
- priv->ule_skb->protocol = dvb_net_eth_type_trans( priv->ule_skb, dev );
- // If D-bit is set (i.e. destination MAC address not present), receive the packet anyhw.
- // if (priv->ule_dbit && skb->pkt_type == PACKET_OTHERHOST)
+ /* Stuff into kernel's protocol stack. */
+ priv->ule_skb->protocol = dvb_net_eth_type_trans(priv->ule_skb, dev);
+ /* If D-bit is set (i.e. destination MAC address not present),
+ * receive the packet anyhw. */
+ /* if (priv->ule_dbit && skb->pkt_type == PACKET_OTHERHOST) */
priv->ule_skb->pkt_type = PACKET_HOST;
((struct dvb_net_priv *) dev->priv)->stats.rx_packets++;
((struct dvb_net_priv *) dev->priv)->stats.rx_bytes += priv->ule_skb->len;
- netif_rx( priv->ule_skb );
+ netif_rx(priv->ule_skb);
}
- // Prepare for next SNDU.
- reset_ule( priv );
+ /* Prepare for next SNDU. */
+ reset_ule(priv);
}
- // More data in current TS (look at the bytes following the CRC32)?
+ /* More data in current TS (look at the bytes following the CRC32)? */
if (ts_remain >= 2 && *((unsigned short *)from_where) != 0xFFFF) {
- // Next ULE SNDU starts right there.
+ /* Next ULE SNDU starts right there. */
new_ts = 0;
priv->ule_skb = NULL;
priv->ule_sndu_type_1 = 0;
priv->ule_sndu_len = 0;
- // printk( KERN_WARNING "More data in current TS: [%#x %#x %#x %#x]\n",
- // *(from_where + 0), *(from_where + 1),
- // *(from_where + 2), *(from_where + 3) );
- // printk( KERN_WARNING "ts @ %p, stopped @ %p:\n", ts, from_where + 0 );
- // hexdump( ts, 188 );
+ // printk(KERN_WARNING "More data in current TS: [%#x %#x %#x %#x]\n",
+ // *(from_where + 0), *(from_where + 1),
+ // *(from_where + 2), *(from_where + 3));
+ // printk(KERN_WARNING "ts @ %p, stopped @ %p:\n", ts, from_where + 0);
+ // hexdump(ts, 188);
} else {
new_ts = 1;
ts += TS_SZ;
@@ -509,21 +551,22 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
priv->ule_sndu_len = 0;
}
}
- } // for all available TS cells
+ } /* for all available TS cells */
}
-static int dvb_net_ts_callback( const u8 *buffer1, size_t buffer1_len,
- const u8 *buffer2, size_t buffer2_len,
- struct dmx_ts_feed *feed, enum dmx_success success )
+static int dvb_net_ts_callback(const u8 *buffer1, size_t buffer1_len,
+ const u8 *buffer2, size_t buffer2_len,
+ struct dmx_ts_feed *feed, enum dmx_success success)
{
struct net_device *dev = (struct net_device *)feed->priv;
if (buffer2 != 0)
- printk( KERN_WARNING "buffer2 not 0: %p.\n", buffer2 );
+ printk(KERN_WARNING "buffer2 not 0: %p.\n", buffer2);
if (buffer1_len > 32768)
- printk( KERN_WARNING "length > 32k: %u.\n", buffer1_len );
- // printk( "TS callback: %u bytes, %u TS cells @ %p.\n", buffer1_len, buffer1_len / TS_SZ, buffer1 );
- dvb_net_ule( dev, buffer1, buffer1_len );
+ printk(KERN_WARNING "length > 32k: %u.\n", buffer1_len);
+ /* printk("TS callback: %u bytes, %u TS cells @ %p.\n",
+ buffer1_len, buffer1_len / TS_SZ, buffer1); */
+ dvb_net_ule(dev, buffer1, buffer1_len);
return 0;
}
@@ -627,7 +670,7 @@ static u8 mask_allmulti[6]={0xff, 0xff, 0xff, 0x00, 0x00, 0x00};
static u8 mac_allmulti[6]={0x01, 0x00, 0x5e, 0x00, 0x00, 0x00};
static u8 mask_promisc[6]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-static int dvb_net_filter_sec_set(struct net_device *dev,
+static int dvb_net_filter_sec_set(struct net_device *dev,
struct dmx_section_filter **secfilter,
u8 *mac, u8 *mac_mask)
{
@@ -678,7 +721,7 @@ static int dvb_net_feed_start(struct net_device *dev)
struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv;
struct dmx_demux *demux = priv->demux;
unsigned char *mac = (unsigned char *) dev->dev_addr;
-
+
dprintk("%s: rx_mode %i\n", __FUNCTION__, priv->rx_mode);
if (priv->secfeed || priv->secfilter || priv->multi_secfilter[0])
printk("%s: BUG %d\n", __FUNCTION__, __LINE__);
@@ -689,7 +732,7 @@ static int dvb_net_feed_start(struct net_device *dev)
if (priv->feedtype == FEEDTYPE_SEC) {
dprintk("%s: alloc secfeed\n", __FUNCTION__);
- ret=demux->allocate_section_feed(demux, &priv->secfeed,
+ ret=demux->allocate_section_feed(demux, &priv->secfeed,
dvb_net_sec_callback);
if (ret<0) {
printk("%s: could not allocate section feed\n", dev->name);
@@ -715,14 +758,14 @@ static int dvb_net_feed_start(struct net_device *dev)
for (i = 0; i < priv->multi_num; i++) {
dprintk("%s: set multi_secfilter[%d]\n", __FUNCTION__, i);
dvb_net_filter_sec_set(dev, &priv->multi_secfilter[i],
- priv->multi_macs[i], mask_normal);
+ priv->multi_macs[i], mask_normal);
}
break;
case RX_MODE_ALL_MULTI:
priv->multi_num=1;
dprintk("%s: set multi_secfilter[0]\n", __FUNCTION__);
dvb_net_filter_sec_set(dev, &priv->multi_secfilter[0],
- mac_allmulti, mask_allmulti);
+ mac_allmulti, mask_allmulti);
break;
case RX_MODE_PROMISC:
priv->multi_num=0;
@@ -730,43 +773,41 @@ static int dvb_net_feed_start(struct net_device *dev)
dvb_net_filter_sec_set(dev, &priv->secfilter, mac, mask_promisc);
break;
}
-
+
dprintk("%s: start filtering\n", __FUNCTION__);
priv->secfeed->start_filtering(priv->secfeed);
}
else {
- struct timespec timeout = { 0, 30000000 }; // 30 msec
-
- // we have payloads encapsulated in TS
- dprintk("%s: alloc tsfeed\n", __FUNCTION__);
- ret = demux->allocate_ts_feed( demux, &priv->tsfeed, dvb_net_ts_callback );
- if (ret < 0) {
- printk("%s: could not allocate ts feed\n", dev->name);
- return ret;
- }
-
- // Set netdevice pointer for ts decaps callback.
- priv->tsfeed->priv = (void *)dev;
- ret = priv->tsfeed->set(priv->tsfeed, // dmx_ts_feed_s
- priv->pid, // PID
- TS_PACKET, // packet type
- DMX_TS_PES_OTHER, // PES type
- 188 * 100, // nr. of bytes delivered per callback
- 32768, // circular buffer size
- 0, // descramble
- timeout); // timeout
-
- if (ret < 0) {
- printk("%s: could not set ts feed\n", dev->name);
- priv->demux->release_ts_feed(priv->demux, priv->tsfeed);
- priv->tsfeed = 0;
- return ret;
- }
-
- dprintk("%s: start filtering\n", __FUNCTION__);
- priv->tsfeed->start_filtering(priv->tsfeed);
- }
-
+ struct timespec timeout = { 0, 30000000 }; // 30 msec
+
+ /* we have payloads encapsulated in TS */
+ dprintk("%s: alloc tsfeed\n", __FUNCTION__);
+ ret = demux->allocate_ts_feed(demux, &priv->tsfeed, dvb_net_ts_callback);
+ if (ret < 0) {
+ printk("%s: could not allocate ts feed\n", dev->name);
+ return ret;
+ }
+
+ /* Set netdevice pointer for ts decaps callback. */
+ priv->tsfeed->priv = (void *)dev;
+ ret = priv->tsfeed->set(priv->tsfeed, priv->pid,
+ TS_PACKET, DMX_TS_PES_OTHER,
+ 188 * 100, /* nr. of bytes delivered per callback */
+ 32768, /* circular buffer size */
+ 0, /* descramble */
+ timeout);
+
+ if (ret < 0) {
+ printk("%s: could not set ts feed\n", dev->name);
+ priv->demux->release_ts_feed(priv->demux, priv->tsfeed);
+ priv->tsfeed = 0;
+ return ret;
+ }
+
+ dprintk("%s: start filtering\n", __FUNCTION__);
+ priv->tsfeed->start_filtering(priv->tsfeed);
+ }
+
return 0;
}
@@ -777,45 +818,46 @@ static void dvb_net_feed_stop(struct net_device *dev)
dprintk("%s\n", __FUNCTION__);
if (priv->feedtype == FEEDTYPE_SEC) {
- if (priv->secfeed) {
+ if (priv->secfeed) {
if (priv->secfeed->is_filtering) {
dprintk("%s: stop secfeed\n", __FUNCTION__);
- priv->secfeed->stop_filtering(priv->secfeed);
+ priv->secfeed->stop_filtering(priv->secfeed);
}
if (priv->secfilter) {
dprintk("%s: release secfilter\n", __FUNCTION__);
priv->secfeed->release_filter(priv->secfeed,
- priv->secfilter);
+ priv->secfilter);
priv->secfilter=0;
}
for (i=0; i<priv->multi_num; i++) {
if (priv->multi_secfilter[i]) {
- dprintk("%s: release multi_filter[%d]\n", __FUNCTION__, i);
+ dprintk("%s: release multi_filter[%d]\n",
+ __FUNCTION__, i);
priv->secfeed->release_filter(priv->secfeed,
- priv->multi_secfilter[i]);
- priv->multi_secfilter[i]=0;
+ priv->multi_secfilter[i]);
+ priv->multi_secfilter[i] = 0;
}
}
priv->demux->release_section_feed(priv->demux, priv->secfeed);
- priv->secfeed=0;
+ priv->secfeed = 0;
} else
printk("%s: no feed to stop\n", dev->name);
}
else {
- if (priv->tsfeed) {
- if (priv->tsfeed->is_filtering) {
- dprintk("%s: stop tsfeed\n", __FUNCTION__);
- priv->tsfeed->stop_filtering(priv->tsfeed);
- }
- priv->demux->release_ts_feed(priv->demux, priv->tsfeed);
- priv->tsfeed = 0;
- }
- else
- printk("%s: no ts feed to stop\n", dev->name);
- }
+ if (priv->tsfeed) {
+ if (priv->tsfeed->is_filtering) {
+ dprintk("%s: stop tsfeed\n", __FUNCTION__);
+ priv->tsfeed->stop_filtering(priv->tsfeed);
+ }
+ priv->demux->release_ts_feed(priv->demux, priv->tsfeed);
+ priv->tsfeed = 0;
+ }
+ else
+ printk("%s: no ts feed to stop\n", dev->name);
+ }
}
@@ -841,8 +883,8 @@ static void wq_set_multicast_list (void *data)
dvb_net_feed_stop(dev);
priv->rx_mode = RX_MODE_UNI;
-
- if(dev->flags & IFF_PROMISC) {
+
+ if (dev->flags & IFF_PROMISC) {
dprintk("%s: promiscuous mode\n", dev->name);
priv->rx_mode = RX_MODE_PROMISC;
} else if ((dev->flags & IFF_ALLMULTI)) {
@@ -858,15 +900,15 @@ static void wq_set_multicast_list (void *data)
priv->rx_mode = RX_MODE_MULTI;
priv->multi_num = 0;
- for (mci = 0, mc=dev->mc_list;
+ for (mci = 0, mc=dev->mc_list;
mci < dev->mc_count;
mc = mc->next, mci++) {
dvb_set_mc_filter(dev, mc);
}
}
- dvb_net_feed_start(dev);
- }
+ dvb_net_feed_start(dev);
+}
static void dvb_net_set_multicast_list (struct net_device *dev)
@@ -939,8 +981,8 @@ static int dvb_net_init_dev (struct net_device *dev)
static void dvb_net_setup(struct net_device *dev)
#endif
{
- struct dvb_net_priv *priv = (struct dvb_net_priv*)dev->priv;
-
+ /* struct dvb_net_priv *priv = (struct dvb_net_priv*)dev->priv; */
+
ether_setup(dev);
dev->open = dvb_net_open;
@@ -955,7 +997,7 @@ static void dvb_net_setup(struct net_device *dev)
dev->hard_header_cache = NULL;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
dev->owner = priv->host->dvbdev->adapter->module;
-#endif
+#endif
dev->flags |= IFF_NOARP;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
return 0;
@@ -985,38 +1027,38 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
struct dvb_net_priv *priv;
int result;
int if_num;
-
+
if ((if_num = get_if(dvbnet)) < 0)
return -EINVAL;
net = &dvbnet->device[if_num];
demux = dvbnet->demux;
-
+
memset(net, 0, sizeof(struct net_device));
memcpy(net->name, "dvb0_0", 7);
net->name[3] = dvbnet->dvbdev->adapter->num + '0';
net->name[5] = if_num + '0';
- net->addr_len = 6;
+ net->addr_len = 6;
memcpy(net->dev_addr, dvbnet->dvbdev->adapter->proposed_mac, 6);
net->next = NULL;
net->init = dvb_net_init_dev;
if (!(net->priv = kmalloc(sizeof(struct dvb_net_priv), GFP_KERNEL)))
return -ENOMEM;
-
+
priv = net->priv;
memset(priv, 0, sizeof(struct dvb_net_priv));
priv->demux = demux;
priv->pid = pid;
priv->rx_mode = RX_MODE_UNI;
priv->host = dvbnet;
-
+
INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list, net);
INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed, net);
net->base_addr = pid;
-
+
if ((result = register_netdev(net)) < 0) {
return result;
}
@@ -1030,7 +1072,7 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
struct dvb_net_priv *priv;
int result;
int if_num;
-
+
if ((if_num = get_if(dvbnet)) < 0)
return -EINVAL;
@@ -1038,14 +1080,14 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
dvb_net_setup);
if (!net)
return -ENOMEM;
-
+
sprintf(net->name, "dvb%d_%d", dvbnet->dvbdev->adapter->num, if_num);
- net->addr_len = 6;
+ net->addr_len = 6;
memcpy(net->dev_addr, dvbnet->dvbdev->adapter->proposed_mac, 6);
dvbnet->device[if_num] = net;
-
+
priv = net->priv;
priv->demux = dvbnet->demux;
priv->pid = pid;
@@ -1063,7 +1105,7 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed, net);
net->base_addr = pid;
-
+
if ((result = register_netdev(net)) < 0) {
dvbnet->device[if_num] = NULL;
free_netdev(net);
@@ -1121,13 +1163,13 @@ static int dvb_net_do_ioctl(struct inode *inode, struct file *file,
if (((file->f_flags&O_ACCMODE)==O_RDONLY))
return -EPERM;
-
+
switch (cmd) {
case NET_ADD_IF:
{
struct dvb_net_if *dvbnetif=(struct dvb_net_if *)parg;
int result;
-
+
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
result=dvb_net_add_if(dvbnet, dvbnetif->pid, dvbnetif->feedtype);
@@ -1207,7 +1249,7 @@ int dvb_net_init (struct dvb_adapter *adap, struct dvb_net *dvbnet,
struct dmx_demux *dmx)
{
int i;
-
+
dvbnet->demux = dmx;
for (i=0; i<DVB_NET_DEVICES_MAX; i++)