--- zzzz-none-000/linux-3.10.107/drivers/media/dvb-core/dvb_net.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/media/dvb-core/dvb_net.c 2021-02-04 17:41:59.000000000 +0000 @@ -68,13 +68,6 @@ #include "dvb_demux.h" #include "dvb_net.h" -static int dvb_net_debug; -module_param(dvb_net_debug, int, 0444); -MODULE_PARM_DESC(dvb_net_debug, "enable debug messages"); - -#define dprintk(x...) do { if (dvb_net_debug) printk(x); } while (0) - - static inline __u32 iov_crc32( __u32 c, struct kvec *iov, unsigned int cnt ) { unsigned int j; @@ -90,36 +83,9 @@ #ifdef ULE_DEBUG -#define MAC_ADDR_PRINTFMT "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x" -#define MAX_ADDR_PRINTFMT_ARGS(macap) (macap)[0],(macap)[1],(macap)[2],(macap)[3],(macap)[4],(macap)[5] - -#define isprint(c) ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')) - -static void hexdump( const unsigned char *buf, unsigned short len ) +static void hexdump(const unsigned char *buf, unsigned short len) { - char str[80], octet[10]; - int ofs, i, l; - - for (ofs = 0; ofs < len; ofs += 16) { - sprintf( str, "%03d: ", ofs ); - - for (i = 0; i < 16; i++) { - if ((i + ofs) < len) - sprintf( octet, "%02x ", buf[ofs + i] ); - else - strcpy( octet, " " ); - - strcat( str, octet ); - } - strcat( str, " " ); - l = strlen( str ); - - for (i = 0; (i < 16) && ((i + ofs) < len); i++) - str[l++] = isprint( buf[ofs + i] ) ? buf[ofs + i] : '.'; - - str[l] = '\0'; - printk( KERN_WARNING "%s\n", str ); - } + print_hex_dump_debug("", DUMP_PREFIX_OFFSET, 16, 1, buf, len, true); } #endif @@ -179,7 +145,7 @@ eth = eth_hdr(skb); if (*eth->h_dest & 1) { - if(memcmp(eth->h_dest,dev->broadcast, ETH_ALEN)==0) + if(ether_addr_equal(eth->h_dest,dev->broadcast)) skb->pkt_type=PACKET_BROADCAST; else skb->pkt_type=PACKET_MULTICAST; @@ -315,9 +281,9 @@ return l; /* Stop extension header processing and discard SNDU. */ total_ext_len += l; #ifdef ULE_DEBUG - dprintk("handle_ule_extensions: ule_next_hdr=%p, ule_sndu_type=%i, " - "l=%i, total_ext_len=%i\n", p->ule_next_hdr, - (int) p->ule_sndu_type, l, total_ext_len); + pr_debug("ule_next_hdr=%p, ule_sndu_type=%i, l=%i, total_ext_len=%i\n", + p->ule_next_hdr, (int)p->ule_sndu_type, + l, total_ext_len); #endif } while (p->ule_sndu_type < ETH_P_802_3_MIN); @@ -379,7 +345,9 @@ /* Check TS error conditions: sync_byte, transport_error_indicator, scrambling_control . */ if ((ts[0] != TS_SYNC) || (ts[1] & TS_TEI) || ((ts[3] & TS_SC) != 0)) { printk(KERN_WARNING "%lu: Invalid TS cell: SYNC %#x, TEI %u, SC %#x.\n", - priv->ts_count, ts[0], ts[1] & TS_TEI >> 7, ts[3] & 0xC0 >> 6); + priv->ts_count, ts[0], + (ts[1] & TS_TEI) >> 7, + (ts[3] & TS_SC) >> 6); /* Drop partly decoded SNDU, reset state, resync on PUSI. */ if (priv->ule_skb) { @@ -674,11 +642,13 @@ if (priv->rx_mode != RX_MODE_PROMISC) { if (priv->ule_skb->data[0] & 0x01) { /* multicast or broadcast */ - if (memcmp(priv->ule_skb->data, bc_addr, ETH_ALEN)) { + if (!ether_addr_equal(priv->ule_skb->data, bc_addr)) { /* multicast */ if (priv->rx_mode == RX_MODE_MULTI) { int i; - for(i = 0; i < priv->multi_num && memcmp(priv->ule_skb->data, priv->multi_macs[i], ETH_ALEN); i++) + for(i = 0; i < priv->multi_num && + !ether_addr_equal(priv->ule_skb->data, + priv->multi_macs[i]); i++) ; if (i == priv->multi_num) drop = 1; @@ -688,7 +658,7 @@ } /* else: broadcast */ } - else if (memcmp(priv->ule_skb->data, dev->dev_addr, ETH_ALEN)) + else if (!ether_addr_equal(priv->ule_skb->data, dev->dev_addr)) drop = 1; /* else: destination address matches the MAC address of our receiver device */ } @@ -696,8 +666,8 @@ if (drop) { #ifdef ULE_DEBUG - dprintk("Dropping SNDU: MAC destination address does not match: dest addr: "MAC_ADDR_PRINTFMT", dev addr: "MAC_ADDR_PRINTFMT"\n", - MAX_ADDR_PRINTFMT_ARGS(priv->ule_skb->data), MAX_ADDR_PRINTFMT_ARGS(dev->dev_addr)); + netdev_dbg(dev, "Dropping SNDU: MAC destination address does not match: dest addr: %pM, dev addr: %pM\n", + priv->ule_skb->data, dev->dev_addr); #endif dev_kfree_skb(priv->ule_skb); goto sndu_done; @@ -739,7 +709,7 @@ if (!priv->ule_dbit) { /* dest_addr buffer is only valid if priv->ule_dbit == 0 */ memcpy(ethh->h_dest, dest_addr, ETH_ALEN); - memset(ethh->h_source, 0, ETH_ALEN); + eth_zero_addr(ethh->h_source); } else /* zeroize source and dest */ memset( ethh, 0, ETH_ALEN*2 ); @@ -791,7 +761,7 @@ 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 dmx_ts_feed *feed) { struct net_device *dev = feed->priv; @@ -900,8 +870,7 @@ static int dvb_net_sec_callback(const u8 *buffer1, size_t buffer1_len, const u8 *buffer2, size_t buffer2_len, - struct dmx_section_filter *filter, - enum dmx_success success) + struct dmx_section_filter *filter) { struct net_device *dev = filter->priv; @@ -960,8 +929,7 @@ (*secfilter)->filter_mask[10] = mac_mask[1]; (*secfilter)->filter_mask[11]=mac_mask[0]; - dprintk("%s: filter mac=%pM\n", dev->name, mac); - dprintk("%s: filter mask=%pM\n", dev->name, mac_mask); + netdev_dbg(dev, "filter mac=%pM mask=%pM\n", mac, mac_mask); return 0; } @@ -973,7 +941,7 @@ struct dmx_demux *demux = priv->demux; unsigned char *mac = (unsigned char *) dev->dev_addr; - dprintk("%s: rx_mode %i\n", __func__, priv->rx_mode); + netdev_dbg(dev, "rx_mode %i\n", priv->rx_mode); mutex_lock(&priv->mutex); if (priv->tsfeed || priv->secfeed || priv->secfilter || priv->multi_secfilter[0]) printk("%s: BUG %d\n", __func__, __LINE__); @@ -983,7 +951,7 @@ priv->tsfeed = NULL; if (priv->feedtype == DVB_NET_FEEDTYPE_MPE) { - dprintk("%s: alloc secfeed\n", __func__); + netdev_dbg(dev, "alloc secfeed\n"); ret=demux->allocate_section_feed(demux, &priv->secfeed, dvb_net_sec_callback); if (ret<0) { @@ -1001,38 +969,38 @@ } if (priv->rx_mode != RX_MODE_PROMISC) { - dprintk("%s: set secfilter\n", __func__); + netdev_dbg(dev, "set secfilter\n"); dvb_net_filter_sec_set(dev, &priv->secfilter, mac, mask_normal); } switch (priv->rx_mode) { case RX_MODE_MULTI: for (i = 0; i < priv->multi_num; i++) { - dprintk("%s: set multi_secfilter[%d]\n", __func__, i); + netdev_dbg(dev, "set multi_secfilter[%d]\n", i); dvb_net_filter_sec_set(dev, &priv->multi_secfilter[i], priv->multi_macs[i], mask_normal); } break; case RX_MODE_ALL_MULTI: priv->multi_num=1; - dprintk("%s: set multi_secfilter[0]\n", __func__); + netdev_dbg(dev, "set multi_secfilter[0]\n"); dvb_net_filter_sec_set(dev, &priv->multi_secfilter[0], mac_allmulti, mask_allmulti); break; case RX_MODE_PROMISC: priv->multi_num=0; - dprintk("%s: set secfilter\n", __func__); + netdev_dbg(dev, "set secfilter\n"); dvb_net_filter_sec_set(dev, &priv->secfilter, mac, mask_promisc); break; } - dprintk("%s: start filtering\n", __func__); + netdev_dbg(dev, "start filtering\n"); priv->secfeed->start_filtering(priv->secfeed); } else if (priv->feedtype == DVB_NET_FEEDTYPE_ULE) { struct timespec timeout = { 0, 10000000 }; // 10 msec /* we have payloads encapsulated in TS */ - dprintk("%s: alloc tsfeed\n", __func__); + netdev_dbg(dev, "alloc tsfeed\n"); 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); @@ -1056,7 +1024,7 @@ goto error; } - dprintk("%s: start filtering\n", __func__); + netdev_dbg(dev, "start filtering\n"); priv->tsfeed->start_filtering(priv->tsfeed); } else ret = -EINVAL; @@ -1071,17 +1039,16 @@ struct dvb_net_priv *priv = netdev_priv(dev); int i, ret = 0; - dprintk("%s\n", __func__); mutex_lock(&priv->mutex); if (priv->feedtype == DVB_NET_FEEDTYPE_MPE) { if (priv->secfeed) { if (priv->secfeed->is_filtering) { - dprintk("%s: stop secfeed\n", __func__); + netdev_dbg(dev, "stop secfeed\n"); priv->secfeed->stop_filtering(priv->secfeed); } if (priv->secfilter) { - dprintk("%s: release secfilter\n", __func__); + netdev_dbg(dev, "release secfilter\n"); priv->secfeed->release_filter(priv->secfeed, priv->secfilter); priv->secfilter=NULL; @@ -1089,8 +1056,8 @@ for (i=0; imulti_num; i++) { if (priv->multi_secfilter[i]) { - dprintk("%s: release multi_filter[%d]\n", - __func__, i); + netdev_dbg(dev, "release multi_filter[%d]\n", + i); priv->secfeed->release_filter(priv->secfeed, priv->multi_secfilter[i]); priv->multi_secfilter[i] = NULL; @@ -1104,7 +1071,7 @@ } else if (priv->feedtype == DVB_NET_FEEDTYPE_ULE) { if (priv->tsfeed) { if (priv->tsfeed->is_filtering) { - dprintk("%s: stop tsfeed\n", __func__); + netdev_dbg(dev, "stop tsfeed\n"); priv->tsfeed->stop_filtering(priv->tsfeed); } priv->demux->release_ts_feed(priv->demux, priv->tsfeed); @@ -1144,16 +1111,16 @@ netif_addr_lock_bh(dev); if (dev->flags & IFF_PROMISC) { - dprintk("%s: promiscuous mode\n", dev->name); + netdev_dbg(dev, "promiscuous mode\n"); priv->rx_mode = RX_MODE_PROMISC; } else if ((dev->flags & IFF_ALLMULTI)) { - dprintk("%s: allmulti mode\n", dev->name); + netdev_dbg(dev, "allmulti mode\n"); priv->rx_mode = RX_MODE_ALL_MULTI; } else if (!netdev_mc_empty(dev)) { struct netdev_hw_addr *ha; - dprintk("%s: set_mc_list, %d entries\n", - dev->name, netdev_mc_count(dev)); + netdev_dbg(dev, "set_mc_list, %d entries\n", + netdev_mc_count(dev)); priv->rx_mode = RX_MODE_MULTI; priv->multi_num = 0; @@ -1222,7 +1189,6 @@ static const struct header_ops dvb_header_ops = { .create = eth_header, .parse = eth_header_parse, - .rebuild = eth_rebuild_header, }; @@ -1274,7 +1240,8 @@ if ((if_num = get_if(dvbnet)) < 0) return -EINVAL; - net = alloc_netdev(sizeof(struct dvb_net_priv), "dvb", dvb_net_setup); + net = alloc_netdev(sizeof(struct dvb_net_priv), "dvb", + NET_NAME_UNKNOWN, dvb_net_setup); if (!net) return -ENOMEM; @@ -1493,14 +1460,16 @@ .llseek = noop_llseek, }; -static struct dvb_device dvbdev_net = { +static const struct dvb_device dvbdev_net = { .priv = NULL, .users = 1, .writers = 1, +#if defined(CONFIG_MEDIA_CONTROLLER_DVB) + .name = "dvb-net", +#endif .fops = &dvb_net_fops, }; - void dvb_net_release (struct dvb_net *dvbnet) { int i;