Lines Matching refs:h

327 static int dvb_net_ule_new_ts_cell(struct dvb_net_ule_handle *h)  in dvb_net_ule_new_ts_cell()  argument
334 memcpy(ule_where, h->ts, TS_SZ); in dvb_net_ule_new_ts_cell()
346 if ((h->ts[0] != TS_SYNC) || (h->ts[1] & TS_TEI) || in dvb_net_ule_new_ts_cell()
347 ((h->ts[3] & TS_SC) != 0)) { in dvb_net_ule_new_ts_cell()
349 h->priv->ts_count, h->ts[0], in dvb_net_ule_new_ts_cell()
350 (h->ts[1] & TS_TEI) >> 7, in dvb_net_ule_new_ts_cell()
351 (h->ts[3] & TS_SC) >> 6); in dvb_net_ule_new_ts_cell()
354 if (h->priv->ule_skb) { in dvb_net_ule_new_ts_cell()
355 dev_kfree_skb(h->priv->ule_skb); in dvb_net_ule_new_ts_cell()
357 h->dev->stats.rx_errors++; in dvb_net_ule_new_ts_cell()
358 h->dev->stats.rx_frame_errors++; in dvb_net_ule_new_ts_cell()
360 reset_ule(h->priv); in dvb_net_ule_new_ts_cell()
361 h->priv->need_pusi = 1; in dvb_net_ule_new_ts_cell()
364 h->ts += TS_SZ; in dvb_net_ule_new_ts_cell()
365 h->priv->ts_count++; in dvb_net_ule_new_ts_cell()
369 h->ts_remain = 184; in dvb_net_ule_new_ts_cell()
370 h->from_where = h->ts + 4; in dvb_net_ule_new_ts_cell()
375 static int dvb_net_ule_ts_pusi(struct dvb_net_ule_handle *h) in dvb_net_ule_ts_pusi() argument
377 if (h->ts[1] & TS_PUSI) { in dvb_net_ule_ts_pusi()
380 h->priv->tscc = h->ts[3] & 0x0F; in dvb_net_ule_ts_pusi()
382 if (h->ts[4] > h->ts_remain) { in dvb_net_ule_ts_pusi()
384 h->priv->ts_count, h->ts[4]); in dvb_net_ule_ts_pusi()
385 h->ts += TS_SZ; in dvb_net_ule_ts_pusi()
386 h->priv->ts_count++; in dvb_net_ule_ts_pusi()
390 h->from_where = &h->ts[5] + h->ts[4]; in dvb_net_ule_ts_pusi()
391 h->ts_remain -= 1 + h->ts[4]; in dvb_net_ule_ts_pusi()
392 h->skipped = 0; in dvb_net_ule_ts_pusi()
394 h->skipped++; in dvb_net_ule_ts_pusi()
395 h->ts += TS_SZ; in dvb_net_ule_ts_pusi()
396 h->priv->ts_count++; in dvb_net_ule_ts_pusi()
403 static int dvb_net_ule_new_ts(struct dvb_net_ule_handle *h) in dvb_net_ule_new_ts() argument
406 if ((h->ts[3] & 0x0F) == h->priv->tscc) in dvb_net_ule_new_ts()
407 h->priv->tscc = (h->priv->tscc + 1) & 0x0F; in dvb_net_ule_new_ts()
411 h->priv->ts_count, h->ts[3] & 0x0F, in dvb_net_ule_new_ts()
412 h->priv->tscc); in dvb_net_ule_new_ts()
414 if (h->priv->ule_skb) { in dvb_net_ule_new_ts()
415 dev_kfree_skb(h->priv->ule_skb); in dvb_net_ule_new_ts()
418 h->dev->stats.rx_errors++; in dvb_net_ule_new_ts()
419 h->dev->stats.rx_frame_errors++; in dvb_net_ule_new_ts()
421 reset_ule(h->priv); in dvb_net_ule_new_ts()
423 h->priv->need_pusi = 1; in dvb_net_ule_new_ts()
432 if (h->ts[1] & TS_PUSI) { in dvb_net_ule_new_ts()
433 if (!h->priv->need_pusi) { in dvb_net_ule_new_ts()
434 if (!(*h->from_where < (h->ts_remain-1)) || in dvb_net_ule_new_ts()
435 *h->from_where != h->priv->ule_sndu_remain) { in dvb_net_ule_new_ts()
441 h->priv->ts_count, in dvb_net_ule_new_ts()
442 *h->from_where); in dvb_net_ule_new_ts()
448 if (h->priv->ule_skb) { in dvb_net_ule_new_ts()
449 h->error = true; in dvb_net_ule_new_ts()
450 dev_kfree_skb(h->priv->ule_skb); in dvb_net_ule_new_ts()
453 if (h->error || h->priv->ule_sndu_remain) { in dvb_net_ule_new_ts()
454 h->dev->stats.rx_errors++; in dvb_net_ule_new_ts()
455 h->dev->stats.rx_frame_errors++; in dvb_net_ule_new_ts()
456 h->error = false; in dvb_net_ule_new_ts()
459 reset_ule(h->priv); in dvb_net_ule_new_ts()
460 h->priv->need_pusi = 1; in dvb_net_ule_new_ts()
467 h->from_where += 1; in dvb_net_ule_new_ts()
468 h->ts_remain -= 1; in dvb_net_ule_new_ts()
470 h->priv->need_pusi = 0; in dvb_net_ule_new_ts()
472 if (h->priv->ule_sndu_remain > 183) { in dvb_net_ule_new_ts()
477 h->dev->stats.rx_errors++; in dvb_net_ule_new_ts()
478 h->dev->stats.rx_length_errors++; in dvb_net_ule_new_ts()
480 h->priv->ts_count, in dvb_net_ule_new_ts()
481 h->priv->ule_sndu_remain, in dvb_net_ule_new_ts()
482 h->ts[4], h->ts_remain); in dvb_net_ule_new_ts()
483 dev_kfree_skb(h->priv->ule_skb); in dvb_net_ule_new_ts()
485 reset_ule(h->priv); in dvb_net_ule_new_ts()
490 h->from_where += h->ts[4]; in dvb_net_ule_new_ts()
491 h->ts_remain -= h->ts[4]; in dvb_net_ule_new_ts()
505 static int dvb_net_ule_new_payload(struct dvb_net_ule_handle *h) in dvb_net_ule_new_payload() argument
507 if (h->ts_remain < 2) { in dvb_net_ule_new_payload()
509 h->ts_remain); in dvb_net_ule_new_payload()
510 h->priv->ule_sndu_len = 0; in dvb_net_ule_new_payload()
511 h->priv->need_pusi = 1; in dvb_net_ule_new_payload()
512 h->ts += TS_SZ; in dvb_net_ule_new_payload()
516 if (!h->priv->ule_sndu_len) { in dvb_net_ule_new_payload()
518 h->priv->ule_sndu_len = h->from_where[0] << 8 | in dvb_net_ule_new_payload()
519 h->from_where[1]; in dvb_net_ule_new_payload()
520 if (h->priv->ule_sndu_len & 0x8000) { in dvb_net_ule_new_payload()
522 h->priv->ule_sndu_len &= 0x7FFF; in dvb_net_ule_new_payload()
523 h->priv->ule_dbit = 1; in dvb_net_ule_new_payload()
525 h->priv->ule_dbit = 0; in dvb_net_ule_new_payload()
527 if (h->priv->ule_sndu_len < 5) { in dvb_net_ule_new_payload()
529 h->priv->ts_count, in dvb_net_ule_new_payload()
530 h->priv->ule_sndu_len); in dvb_net_ule_new_payload()
531 h->dev->stats.rx_errors++; in dvb_net_ule_new_payload()
532 h->dev->stats.rx_length_errors++; in dvb_net_ule_new_payload()
533 h->priv->ule_sndu_len = 0; in dvb_net_ule_new_payload()
534 h->priv->need_pusi = 1; in dvb_net_ule_new_payload()
535 h->new_ts = 1; in dvb_net_ule_new_payload()
536 h->ts += TS_SZ; in dvb_net_ule_new_payload()
537 h->priv->ts_count++; in dvb_net_ule_new_payload()
540 h->ts_remain -= 2; /* consume the 2 bytes SNDU length. */ in dvb_net_ule_new_payload()
541 h->from_where += 2; in dvb_net_ule_new_payload()
544 h->priv->ule_sndu_remain = h->priv->ule_sndu_len + 2; in dvb_net_ule_new_payload()
552 switch (h->ts_remain) { in dvb_net_ule_new_payload()
554 h->priv->ule_sndu_remain--; in dvb_net_ule_new_payload()
555 h->priv->ule_sndu_type = h->from_where[0] << 8; in dvb_net_ule_new_payload()
558 h->priv->ule_sndu_type_1 = 1; in dvb_net_ule_new_payload()
559 h->ts_remain -= 1; in dvb_net_ule_new_payload()
560 h->from_where += 1; in dvb_net_ule_new_payload()
563 h->new_ts = 1; in dvb_net_ule_new_payload()
564 h->ts += TS_SZ; in dvb_net_ule_new_payload()
565 h->priv->ts_count++; in dvb_net_ule_new_payload()
570 if (h->priv->ule_sndu_type_1) { in dvb_net_ule_new_payload()
571 h->priv->ule_sndu_type_1 = 0; in dvb_net_ule_new_payload()
572 h->priv->ule_sndu_type |= h->from_where[0]; in dvb_net_ule_new_payload()
573 h->from_where += 1; /* points to payload start. */ in dvb_net_ule_new_payload()
574 h->ts_remain -= 1; in dvb_net_ule_new_payload()
577 h->priv->ule_sndu_type = h->from_where[0] << 8 | in dvb_net_ule_new_payload()
578 h->from_where[1]; in dvb_net_ule_new_payload()
579 h->from_where += 2; /* points to payload start. */ in dvb_net_ule_new_payload()
580 h->ts_remain -= 2; in dvb_net_ule_new_payload()
592 h->priv->ule_skb = dev_alloc_skb(h->priv->ule_sndu_len + in dvb_net_ule_new_payload()
594 if (!h->priv->ule_skb) { in dvb_net_ule_new_payload()
596 h->dev->name); in dvb_net_ule_new_payload()
597 h->dev->stats.rx_dropped++; in dvb_net_ule_new_payload()
602 h->priv->ule_sndu_remain = h->priv->ule_sndu_len; in dvb_net_ule_new_payload()
603 h->priv->ule_skb->dev = h->dev; in dvb_net_ule_new_payload()
608 skb_reserve(h->priv->ule_skb, ETH_HLEN + ETH_ALEN); in dvb_net_ule_new_payload()
614 static int dvb_net_ule_should_drop(struct dvb_net_ule_handle *h) in dvb_net_ule_should_drop() argument
624 if (h->priv->rx_mode == RX_MODE_PROMISC) in dvb_net_ule_should_drop()
627 if (h->priv->ule_skb->data[0] & 0x01) { in dvb_net_ule_should_drop()
629 if (!ether_addr_equal(h->priv->ule_skb->data, bc_addr)) { in dvb_net_ule_should_drop()
631 if (h->priv->rx_mode == RX_MODE_MULTI) { in dvb_net_ule_should_drop()
634 for (i = 0; i < h->priv->multi_num && in dvb_net_ule_should_drop()
635 !ether_addr_equal(h->priv->ule_skb->data, in dvb_net_ule_should_drop()
636 h->priv->multi_macs[i]); in dvb_net_ule_should_drop()
639 if (i == h->priv->multi_num) in dvb_net_ule_should_drop()
641 } else if (h->priv->rx_mode != RX_MODE_ALL_MULTI) in dvb_net_ule_should_drop()
649 } else if (!ether_addr_equal(h->priv->ule_skb->data, h->dev->dev_addr)) in dvb_net_ule_should_drop()
656 static void dvb_net_ule_check_crc(struct dvb_net_ule_handle *h, in dvb_net_ule_check_crc() argument
664 h->priv->ts_count, ule_crc, expected_crc, in dvb_net_ule_check_crc()
665 h->priv->ule_sndu_len, h->priv->ule_sndu_type, in dvb_net_ule_check_crc()
666 h->ts_remain, in dvb_net_ule_check_crc()
667 h->ts_remain > 2 ? in dvb_net_ule_check_crc()
668 *(unsigned short *)h->from_where : 0); in dvb_net_ule_check_crc()
688 h->dev->stats.rx_errors++; in dvb_net_ule_check_crc()
689 h->dev->stats.rx_crc_errors++; in dvb_net_ule_check_crc()
690 dev_kfree_skb(h->priv->ule_skb); in dvb_net_ule_check_crc()
698 h->priv->ule_skb->tail -= 4; in dvb_net_ule_check_crc()
699 h->priv->ule_skb->len -= 4; in dvb_net_ule_check_crc()
701 if (!h->priv->ule_dbit) { in dvb_net_ule_check_crc()
702 if (dvb_net_ule_should_drop(h)) { in dvb_net_ule_check_crc()
703 netdev_dbg(h->dev, in dvb_net_ule_check_crc()
705 h->priv->ule_skb->data, h->dev->dev_addr); in dvb_net_ule_check_crc()
706 dev_kfree_skb(h->priv->ule_skb); in dvb_net_ule_check_crc()
710 skb_copy_from_linear_data(h->priv->ule_skb, dest_addr, in dvb_net_ule_check_crc()
712 skb_pull(h->priv->ule_skb, ETH_ALEN); in dvb_net_ule_check_crc()
719 if (h->priv->ule_sndu_type < ETH_P_802_3_MIN) { in dvb_net_ule_check_crc()
721 int l = handle_ule_extensions(h->priv); in dvb_net_ule_check_crc()
730 dev_kfree_skb(h->priv->ule_skb); in dvb_net_ule_check_crc()
733 skb_pull(h->priv->ule_skb, l); in dvb_net_ule_check_crc()
744 if (!h->priv->ule_bridged) { in dvb_net_ule_check_crc()
745 skb_push(h->priv->ule_skb, ETH_HLEN); in dvb_net_ule_check_crc()
746 h->ethh = (struct ethhdr *)h->priv->ule_skb->data; in dvb_net_ule_check_crc()
747 memcpy(h->ethh->h_dest, dest_addr, ETH_ALEN); in dvb_net_ule_check_crc()
748 eth_zero_addr(h->ethh->h_source); in dvb_net_ule_check_crc()
749 h->ethh->h_proto = htons(h->priv->ule_sndu_type); in dvb_net_ule_check_crc()
752 h->priv->ule_bridged = 0; in dvb_net_ule_check_crc()
755 h->priv->ule_skb->protocol = dvb_net_eth_type_trans(h->priv->ule_skb, in dvb_net_ule_check_crc()
756 h->dev); in dvb_net_ule_check_crc()
762 if (h->priv->ule_dbit && skb->pkt_type == PACKET_OTHERHOST) in dvb_net_ule_check_crc()
763 h->priv->ule_skb->pkt_type = PACKET_HOST; in dvb_net_ule_check_crc()
765 h->dev->stats.rx_packets++; in dvb_net_ule_check_crc()
766 h->dev->stats.rx_bytes += h->priv->ule_skb->len; in dvb_net_ule_check_crc()
767 netif_rx(h->priv->ule_skb); in dvb_net_ule_check_crc()
773 struct dvb_net_ule_handle h = { in dvb_net_ule() local
793 for (h.ts = h.buf, h.ts_end = h.buf + h.buf_len; in dvb_net_ule()
794 h.ts < h.ts_end; /* no incr. */) { in dvb_net_ule()
795 if (h.new_ts) { in dvb_net_ule()
797 if (dvb_net_ule_new_ts_cell(&h)) in dvb_net_ule()
802 if (h.priv->need_pusi) { in dvb_net_ule()
803 if (dvb_net_ule_ts_pusi(&h)) in dvb_net_ule()
807 if (h.new_ts) { in dvb_net_ule()
808 if (dvb_net_ule_new_ts(&h)) in dvb_net_ule()
813 if (h.priv->ule_skb == NULL) { in dvb_net_ule()
814 ret = dvb_net_ule_new_payload(&h); in dvb_net_ule()
822 h.how_much = min(h.priv->ule_sndu_remain, (int)h.ts_remain); in dvb_net_ule()
823 skb_put_data(h.priv->ule_skb, h.from_where, h.how_much); in dvb_net_ule()
824 h.priv->ule_sndu_remain -= h.how_much; in dvb_net_ule()
825 h.ts_remain -= h.how_much; in dvb_net_ule()
826 h.from_where += h.how_much; in dvb_net_ule()
829 if (h.priv->ule_sndu_remain <= 0) { in dvb_net_ule()
831 __be16 ulen = htons(h.priv->ule_sndu_len); in dvb_net_ule()
832 __be16 utype = htons(h.priv->ule_sndu_type); in dvb_net_ule()
837 { h.priv->ule_skb->data, in dvb_net_ule()
838 h.priv->ule_skb->len - 4 } in dvb_net_ule()
841 if (h.priv->ule_dbit) { in dvb_net_ule()
848 tail = skb_tail_pointer(h.priv->ule_skb); in dvb_net_ule()
854 dvb_net_ule_check_crc(&h, iov, ule_crc, expected_crc); in dvb_net_ule()
857 reset_ule(h.priv); in dvb_net_ule()
861 if (h.ts_remain >= 2 && *((unsigned short *)h.from_where) != 0xFFFF) { in dvb_net_ule()
863 h.new_ts = 0; in dvb_net_ule()
864 h.priv->ule_skb = NULL; in dvb_net_ule()
865 h.priv->ule_sndu_type_1 = 0; in dvb_net_ule()
866 h.priv->ule_sndu_len = 0; in dvb_net_ule()
873 h.new_ts = 1; in dvb_net_ule()
874 h.ts += TS_SZ; in dvb_net_ule()
875 h.priv->ts_count++; in dvb_net_ule()
876 if (h.priv->ule_skb == NULL) { in dvb_net_ule()
877 h.priv->need_pusi = 1; in dvb_net_ule()
878 h.priv->ule_sndu_type_1 = 0; in dvb_net_ule()
879 h.priv->ule_sndu_len = 0; in dvb_net_ule()