staging: r8188eu: Remove unused code
cover staging: r8188eu: Remove unused code
Remove unused code from the r8188eu driver.
Fabio M. De Francesco (3):
staging: r8188eu: Remove unused nat25_handle_frame()
staging: r8188eu: Remove all code depending on the NAT25_LOOKUP method
staging: r8188eu: Remove no more used variable and function
drivers/staging/r8188eu/core/rtw_br_ext.c | 263 +------------------ drivers/staging/r8188eu/include/recv_osdep.h | 1 - drivers/staging/r8188eu/include/rtw_br_ext.h | 1 - 3 files changed, 1 insertion(+), 264 deletions(-)
Signature · 1 line
2.32.0
PATCH 1/3 staging: r8188eu: Remove unused nat25_handle_frame()
Remove nat25_handle_frame() because it is not called by any other function of the driver.
--- drivers/staging/r8188eu/core/rtw_br_ext.c | 61 -------------------- drivers/staging/r8188eu/include/recv_osdep.h | 1 - 2 files changed, 62 deletions(-)
drivers/staging/r8188eu/core/rtw_br_ext.c +0 -61
@@ -1019,67 +1019,6 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method)return -1 ; } -int nat25_handle_frame (struct adapter *priv,struct sk_buff *skb) -{ -if (!(skb->data[0 ] &1 )) { -int is_vlan_tag =0 , i, retval =0 ; -unsigned short vlan_hdr =0 ; -unsigned short protocol; - - protocol =be16_to_cpu (*((__be16 *)(skb->data +2 *ETH_ALEN ))); -if (protocol ==ETH_P_8021Q ) { - is_vlan_tag =1 ; - vlan_hdr = *((unsigned short *)(skb->data+ETH_ALEN *2 +2 )); -for (i =0 ; i <6 ; i++) - *((unsigned short *)(skb->data+ETH_ALEN *2 +2 -i*2 )) = *((unsigned short *)(skb->data+ETH_ALEN *2 -2 -i*2 )); -skb_pull (skb,4 ); - } - -if (!priv->ethBrExtInfo.nat25_disable) { -spin_lock_bh (&priv->br_ext_lock); -/* -* This function look up the destination network address from -* the NAT2.5 database. Return value = -1 means that the -* corresponding network protocol is NOT support. -*/ -if (!priv->ethBrExtInfo.nat25sc_disable && - (be16_to_cpu (*((__be16 *)(skb->data+ETH_ALEN *2 ))) ==ETH_P_IP ) && - !memcmp (priv->scdb_ip, skb->data+ETH_HLEN +16 ,4 )) { -memcpy (skb->data, priv->scdb_mac,ETH_ALEN ); - -spin_unlock_bh (&priv->br_ext_lock); - }else { -spin_unlock_bh (&priv->br_ext_lock); - - retval =nat25_db_handle (priv, skb,NAT25_LOOKUP ); - } - }else { -if (((be16_to_cpu (*((__be16 *)(skb->data+ETH_ALEN *2 ))) ==ETH_P_IP ) && - !memcmp (priv->br_ip, skb->data+ETH_HLEN +16 ,4 )) || - ((be16_to_cpu (*((__be16 *)(skb->data+ETH_ALEN *2 ))) ==ETH_P_ARP ) && - !memcmp (priv->br_ip, skb->data+ETH_HLEN +24 ,4 ))) { -/* for traffic to upper TCP/IP */ - retval =nat25_db_handle (priv, skb,NAT25_LOOKUP ); - } - } - -if (is_vlan_tag) { -skb_push (skb,4 ); -for (i =0 ; i <6 ; i++) - *((unsigned short *)(skb->data+i*2 )) = *((unsigned short *)(skb->data+4 +i*2 )); - *((__be16 *)(skb->data+ETH_ALEN *2 )) =__constant_htons (ETH_P_8021Q ); - *((unsigned short *)(skb->data+ETH_ALEN *2 +2 )) = vlan_hdr; - } - -if (retval ==-1 ) { -/* DEBUG_ERR("NAT25: Lookup fail!\n"); */ -return -1 ; - } - } - -return 0 ; -} -#define SERVER_PORT 67#define CLIENT_PORT 68#define DHCP_MAGIC 0x63825363
drivers/staging/r8188eu/include/recv_osdep.h +0 -1
@@ -30,7 +30,6 @@ int rtw_os_recvbuf_resource_free(struct adapter *adapt, struct recv_buf *buf);void rtw_os_read_port (struct adapter *padapter,struct recv_buf *precvbuf);void rtw_init_recv_timer (struct recv_reorder_ctrl *preorder_ctrl); -int nat25_handle_frame (struct adapter *priv,struct sk_buff *skb);int _netdev_open (struct net_device *pnetdev);int netdev_open (struct net_device *pnetdev);int netdev_close (struct net_device *pnetdev);
Signature · 1 line
2.32.0
PATCH 2/3 staging: r8188eu: Remove code depending on NAT25_LOOKUP
In reply to Fabio M. De FrancescoRemove all the code related to the management of the NAT25_LOOKUP method in nat25_db_handle(). The only function that used that method was the now deleted nat25_handle_frame(). Remove the NAT25_LOOKUP entry from the NAT25_METHOD enum because it is not anymore used everywhere else in the code of the driver.
--- drivers/staging/r8188eu/core/rtw_br_ext.c | 150 ------------------- drivers/staging/r8188eu/include/rtw_br_ext.h | 1 - 2 files changed, 151 deletions(-)
drivers/staging/r8188eu/core/rtw_br_ext.c +0 -150
@@ -515,27 +515,6 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method)__nat25_db_print (priv);return 0 ; -case NAT25_LOOKUP : -DEBUG_INFO ("NAT25: Lookup IP, SA =%08x, DA =%08x\n" , iph->saddr, iph->daddr); - tmp =be32_to_cpu (iph->daddr); -__nat25_generate_ipv4_network_addr (networkAddr, &tmp); - -if (!__nat25_db_network_lookup_and_replace (priv, skb, networkAddr)) { -if (*((unsigned char *)&iph->daddr +3 ) ==0xff ) { -/* L2 is unicast but L3 is broadcast, make L2 bacome broadcast */ -DEBUG_INFO ("NAT25: Set DA as boardcast\n" ); -memset (skb->data,0xff ,ETH_ALEN ); - }else { -/* forward unknow IP packet to upper TCP/IP */ -DEBUG_INFO ("NAT25: Replace DA with BR's MAC\n" ); -if ((*(u32 *)priv->br_mac) ==0 && (*(u16 *)(priv->br_mac+4 )) ==0 ) { -printk ("Re-init netdev_br_init() due to br_mac == 0!\n" ); -netdev_br_init (priv->pnetdev); - } -memcpy (skb->data, priv->br_mac,ETH_ALEN ); - } - } -return 0 ;default :return -1 ; }
@@ -567,20 +546,6 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method)__nat25_db_network_insert (priv, skb->data+ETH_ALEN , networkAddr);__nat25_db_print (priv);return 0 ; -case NAT25_LOOKUP : -DEBUG_INFO ("NAT25: Lookup ARP\n" ); - - arp_ptr += arp->ar_hln; - sender = (unsigned int *)arp_ptr; - arp_ptr += (arp->ar_hln + arp->ar_pln); - target = (unsigned int *)arp_ptr; -__nat25_generate_ipv4_network_addr (networkAddr, target); -__nat25_db_network_lookup_and_replace (priv, skb, networkAddr); -/* change to ARP target mac address to Lookup result */ - arp_ptr = (unsigned char *)(arp +1 ); - arp_ptr += (arp->ar_hln + arp->ar_pln); -memcpy (arp_ptr, skb->data,ETH_ALEN ); -return 0 ;default :return -1 ; }
@@ -687,22 +652,6 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method)__nat25_db_network_insert (priv, skb->data+ETH_ALEN , networkAddr);__nat25_db_print (priv);return 0 ; -case NAT25_LOOKUP : -if (!memcmp (GET_MY_HWADDR (priv), ipx->ipx_dest.node,ETH_ALEN )) { -DEBUG_INFO ("NAT25: Lookup IPX, Modify Destination IPX Node addr\n" ); - -__nat25_generate_ipx_network_addr_with_socket (networkAddr, &ipx->ipx_dest.net, &ipx->ipx_dest.sock); - -__nat25_db_network_lookup_and_replace (priv, skb, networkAddr); - -/* replace IPX destination node addr with Lookup destination MAC addr */ -memcpy (ipx->ipx_dest.node, skb->data,ETH_ALEN ); - }else { -__nat25_generate_ipx_network_addr_with_node (networkAddr, &ipx->ipx_dest.net, ipx->ipx_dest.node); - -__nat25_db_network_lookup_and_replace (priv, skb, networkAddr); - } -return 0 ;default :return -1 ; }
@@ -732,19 +681,6 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method)__nat25_db_print (priv);return 0 ; -case NAT25_LOOKUP : -DEBUG_INFO ("NAT25: Lookup AARP, Source =%d,%d Destination =%d,%d\n" , - ea->pa_src_net, - ea->pa_src_node, - ea->pa_dst_net, - ea->pa_dst_node); - -__nat25_generate_apple_network_addr (networkAddr, &ea->pa_dst_net, &ea->pa_dst_node); - -__nat25_db_network_lookup_and_replace (priv, skb, networkAddr); - -/* change to AARP destination mac address to Lookup result */ -memcpy (ea->hw_dst, skb->data,ETH_ALEN );return 0 ;default :return -1 ;
@@ -766,15 +702,6 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method)__nat25_db_print (priv);return 0 ; -case NAT25_LOOKUP : -DEBUG_INFO ("NAT25: Lookup DDP, Source =%d,%d Destination =%d,%d\n" , - ddp->deh_snet, - ddp->deh_snode, - ddp->deh_dnet, - ddp->deh_dnode); -__nat25_generate_apple_network_addr (networkAddr, &ddp->deh_dnet, &ddp->deh_dnode); -__nat25_db_network_lookup_and_replace (priv, skb, networkAddr); -return 0 ;default :return -1 ; }
@@ -865,70 +792,6 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) priv->pppoe_connection_in_progress =0 ; }return 0 ; -case NAT25_LOOKUP : -if (ph->code ==PADO_CODE || ph->code ==PADS_CODE ) { -if (priv->ethBrExtInfo.addPPPoETag) { -struct pppoe_tag *tag; -unsigned char *ptr; -unsigned short tagType, tagLen; -int offset =0 ; - - ptr =__nat25_find_pppoe_tag (ph,ntohs (PTT_RELAY_SID )); -if (!ptr) { -DEBUG_ERR ("Fail to find PTT_RELAY_SID in FADO!\n" ); -return -1 ; - } - - tag = (struct pppoe_tag *)ptr; - tagType = (unsigned short )((ptr[0 ] <<8 ) + ptr[1 ]); - tagLen = (unsigned short )((ptr[2 ] <<8 ) + ptr[3 ]); - -if ((tagType !=ntohs (PTT_RELAY_SID )) || (tagLen < (MAGIC_CODE_LEN +RTL_RELAY_TAG_LEN ))) { -DEBUG_ERR ("Invalid PTT_RELAY_SID tag length [%d]!\n" , tagLen); -return -1 ; - } - - pMagic = (unsigned short *)tag->tag_data; -if (ntohs (*pMagic) !=MAGIC_CODE ) { -DEBUG_ERR ("Can't find MAGIC_CODE in %s packet!\n" , - (ph->code ==PADO_CODE ?"PADO" :"PADS" )); -return -1 ; - } - -memcpy (skb->data, tag->tag_data+MAGIC_CODE_LEN ,ETH_ALEN ); - -if (tagLen >MAGIC_CODE_LEN +RTL_RELAY_TAG_LEN ) - offset =TAG_HDR_LEN ; - -if (skb_pull_and_merge (skb, ptr+offset,TAG_HDR_LEN +MAGIC_CODE_LEN +RTL_RELAY_TAG_LEN -offset) <0 ) { -DEBUG_ERR ("call skb_pull_and_merge() failed in PADO packet!\n" ); -return -1 ; - } - ph->length =htons (ntohs (ph->length)-(TAG_HDR_LEN +MAGIC_CODE_LEN +RTL_RELAY_TAG_LEN -offset)); -if (offset >0 ) - tag->tag_len =htons (tagLen-MAGIC_CODE_LEN -RTL_RELAY_TAG_LEN ); - -DEBUG_INFO ("NAT25: Lookup PPPoE, forward %s Packet from %s\n" , - (ph->code ==PADO_CODE ?"PADO" :"PADS" ), skb->dev->name); - }else {/* not add relay tag */ -if (!priv->pppoe_connection_in_progress) { -DEBUG_ERR ("Discard PPPoE packet due to no connection in progresss!\n" ); -return -1 ; - } -memcpy (skb->data, priv->pppoe_addr,ETH_ALEN ); - priv->pppoe_connection_in_progress =WAIT_TIME_PPPOE ; - } - }else { -if (ph->sid !=0 ) { -DEBUG_INFO ("NAT25: Lookup PPPoE, lookup session packet from %s\n" , skb->dev->name); -__nat25_generate_pppoe_network_addr (networkAddr, skb->data+ETH_ALEN , &ph->sid); -__nat25_db_network_lookup_and_replace (priv, skb, networkAddr); -__nat25_db_print (priv); - }else { -return -1 ; - } - } -return 0 ;default :return -1 ; }
@@ -941,8 +804,6 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method)return -1 ;case NAT25_INSERT :return 0 ; -case NAT25_LOOKUP : -return 0 ;default :return -1 ; }
@@ -955,8 +816,6 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method)return -1 ;case NAT25_INSERT :return 0 ; -case NAT25_LOOKUP : -return 0 ;default :return -1 ; }
@@ -1003,15 +862,6 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) } }return 0 ; -case NAT25_LOOKUP : -DEBUG_INFO ("NAT25: Lookup IP, SA =%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x, DA =%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x\n" , - iph->saddr.s6_addr16[0 ], iph->saddr.s6_addr16[1 ], iph->saddr.s6_addr16[2 ], iph->saddr.s6_addr16[3 ], - iph->saddr.s6_addr16[4 ], iph->saddr.s6_addr16[5 ], iph->saddr.s6_addr16[6 ], iph->saddr.s6_addr16[7 ], - iph->daddr.s6_addr16[0 ], iph->daddr.s6_addr16[1 ], iph->daddr.s6_addr16[2 ], iph->daddr.s6_addr16[3 ], - iph->daddr.s6_addr16[4 ], iph->daddr.s6_addr16[5 ], iph->daddr.s6_addr16[6 ], iph->daddr.s6_addr16[7 ]); -__nat25_generate_ipv6_network_addr (networkAddr, (unsigned int *)&iph->daddr); -__nat25_db_network_lookup_and_replace (priv, skb, networkAddr); -return 0 ;default :return -1 ; }
drivers/staging/r8188eu/include/rtw_br_ext.h +0 -1
@@ -31,7 +31,6 @@ enum NAT25_METHOD {NAT25_MIN ,NAT25_CHECK ,NAT25_INSERT , -NAT25_LOOKUP ,NAT25_PARSE , NAT25_MAX };
Signature · 1 line
2.32.0
PATCH 3/3 staging: r8188eu: Remove no more used variable and function
In reply to Fabio M. De FrancescoRemove the 'sender' pointer to integer. Remove __nat25_db_network_lookup_and_replace(). Following the deletion of the code related to the NAT25_LOOKUP method, they are no more needed.
--- drivers/staging/r8188eu/core/rtw_br_ext.c | 52 +---------------------- 1 file changed, 1 insertion(+), 51 deletions(-)
drivers/staging/r8188eu/core/rtw_br_ext.c +1 -51
@@ -326,56 +326,6 @@ static inline void __network_hash_unlink(struct nat25_network_db_entry *ent) ent->pprev_hash =NULL ; } -static int __nat25_db_network_lookup_and_replace (struct adapter *priv, -struct sk_buff *skb,unsigned char *networkAddr) -{ -struct nat25_network_db_entry *db; - -spin_lock_bh (&priv->br_ext_lock); - - db = priv->nethash[__nat25_network_hash (networkAddr)]; -while (db) { -if (!memcmp (db->networkAddr, networkAddr,MAX_NETWORK_ADDR_LEN )) { -if (!__nat25_has_expired (priv, db)) { -/* replace the destination mac address */ -memcpy (skb->data, db->macAddr,ETH_ALEN ); -atomic_inc (&db->use_count); - -DEBUG_INFO ("NAT25: Lookup M:%02x%02x%02x%02x%02x%02x N:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" -"%02x%02x%02x%02x%02x%02x\n" , - db->macAddr[0 ], - db->macAddr[1 ], - db->macAddr[2 ], - db->macAddr[3 ], - db->macAddr[4 ], - db->macAddr[5 ], - db->networkAddr[0 ], - db->networkAddr[1 ], - db->networkAddr[2 ], - db->networkAddr[3 ], - db->networkAddr[4 ], - db->networkAddr[5 ], - db->networkAddr[6 ], - db->networkAddr[7 ], - db->networkAddr[8 ], - db->networkAddr[9 ], - db->networkAddr[10 ], - db->networkAddr[11 ], - db->networkAddr[12 ], - db->networkAddr[13 ], - db->networkAddr[14 ], - db->networkAddr[15 ], - db->networkAddr[16 ]); - } -spin_unlock_bh (&priv->br_ext_lock); -return 1 ; - } - db = db->next_hash; - } -spin_unlock_bh (&priv->br_ext_lock); -return 0 ; -} -static void __nat25_db_network_insert (struct adapter *priv,unsigned char *macAddr,unsigned char *networkAddr) {
@@ -524,7 +474,7 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method)/*---------------------------------------------------*/ struct arphdr *arp = (struct arphdr *)(skb->data +ETH_HLEN );unsigned char *arp_ptr = (unsigned char *)(arp +1 ); -unsigned int *sender, *target; +unsigned int *sender;if (arp->ar_pro !=__constant_htons (ETH_P_IP )) {DEBUG_WARN ("NAT25: arp protocol unknown (%4x)!\n" ,be16_to_cpu (arp->ar_pro));
Signature · 1 line
2.32.0
Quoted 7 lines · Fabio M. De Francesco
Remove unused code from the r8188eu driver.
Fabio M. De Francesco (3):
staging: r8188eu: Remove unusednat25_handle_frame()
staging: r8188eu: Remove all code depending on theNAT25_LOOKUPmethod
staging: r8188eu: Remove no more used variable and function
Quoted 5 lines
drivers/staging/r8188eu/core/rtw_br_ext.c | 263 +------------------ drivers/staging/r8188eu/include/recv_osdep.h | 1 - drivers/staging/r8188eu/include/rtw_br_ext.h | 1 - 3 files changed, 1 insertion(+), 264 deletions(-)
Looks good to me, thanks.
Regards,
Michael
Greg Kroah-Hartman
maintainerQuoted 11 lines · Fabio M. De Francesco
Remove unused code from the r8188eu driver.
Fabio M. De Francesco (3):
staging: r8188eu: Remove unusednat25_handle_frame()
staging: r8188eu: Remove all code depending on theNAT25_LOOKUPmethod
staging: r8188eu: Remove no more used variable and functiondrivers/staging/r8188eu/core/rtw_br_ext.c | 263 +------------------ drivers/staging/r8188eu/include/recv_osdep.h | 1 - drivers/staging/r8188eu/include/rtw_br_ext.h | 1 - 3 files changed, 1 insertion(+), 264 deletions(-)
Patch 2/3 did not apply, can you please rebase and resend the remaining 2 patches against my latest tree?
thanks,
greg k-h
Quoted 8 lines · CEST Greg Kroah-Hartman
Quoted 7 lines · Fabio M. De Francesco
Remove unused code from the r8188eu driver.
Fabio M. De Francesco (3):
staging: r8188eu: Remove unusednat25_handle_frame()
staging: r8188eu: Remove all code depending on theNAT25_LOOKUPmethod
staging: r8188eu: Remove no more used variable and function
Quoted 7 lines
Quoted 4 lines
drivers/staging/r8188eu/core/rtw_br_ext.c | 263 +------------------ drivers/staging/r8188eu/include/recv_osdep.h | 1 - drivers/staging/r8188eu/include/rtw_br_ext.h | 1 - 3 files changed, 1 insertion(+), 264 deletions(-)Patch 2/3 did not apply, can you please rebase and resend the remaining 2 patches against my latest tree?
Sure. I've already sent them:
"[PATCH v2 2/3] staging: r8188eu: Remove code depending on NAT25_LOOKUP",
https://lkml.org/lkml/2021/8/16/1082;
"[PATCH v2 3/3] staging: r8188eu: Remove no more used variable and function",
https://lkml.org/lkml/2021/8/16/1094.
Thanks,
Fabio
Quoted 3 lines
thanks,
greg k-h