@@ -40,48 +40,6 @@ static struct i40e_vsi *i40e_dbg_find_vsi(struct i40e_pf *pf, int seid)
40
40
* setup, adding or removing filters, or other things. Many of
41
41
* these will be useful for some forms of unit testing.
42
42
**************************************************************/
43
- static char i40e_dbg_command_buf [256 ] = "" ;
44
-
45
- /**
46
- * i40e_dbg_command_read - read for command datum
47
- * @filp: the opened file
48
- * @buffer: where to write the data for the user to read
49
- * @count: the size of the user's buffer
50
- * @ppos: file position offset
51
- **/
52
- static ssize_t i40e_dbg_command_read (struct file * filp , char __user * buffer ,
53
- size_t count , loff_t * ppos )
54
- {
55
- struct i40e_pf * pf = filp -> private_data ;
56
- struct i40e_vsi * main_vsi ;
57
- int bytes_not_copied ;
58
- int buf_size = 256 ;
59
- char * buf ;
60
- int len ;
61
-
62
- /* don't allow partial reads */
63
- if (* ppos != 0 )
64
- return 0 ;
65
- if (count < buf_size )
66
- return - ENOSPC ;
67
-
68
- buf = kzalloc (buf_size , GFP_KERNEL );
69
- if (!buf )
70
- return - ENOSPC ;
71
-
72
- main_vsi = i40e_pf_get_main_vsi (pf );
73
- len = snprintf (buf , buf_size , "%s: %s\n" , main_vsi -> netdev -> name ,
74
- i40e_dbg_command_buf );
75
-
76
- bytes_not_copied = copy_to_user (buffer , buf , len );
77
- kfree (buf );
78
-
79
- if (bytes_not_copied )
80
- return - EFAULT ;
81
-
82
- * ppos = len ;
83
- return len ;
84
- }
85
43
86
44
static char * i40e_filter_state_string [] = {
87
45
"INVALID" ,
@@ -1621,7 +1579,6 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
1621
1579
static const struct file_operations i40e_dbg_command_fops = {
1622
1580
.owner = THIS_MODULE ,
1623
1581
.open = simple_open ,
1624
- .read = i40e_dbg_command_read ,
1625
1582
.write = i40e_dbg_command_write ,
1626
1583
};
1627
1584
@@ -1630,48 +1587,6 @@ static const struct file_operations i40e_dbg_command_fops = {
1630
1587
* The netdev_ops entry in debugfs is for giving the driver commands
1631
1588
* to be executed from the netdev operations.
1632
1589
**************************************************************/
1633
- static char i40e_dbg_netdev_ops_buf [256 ] = "" ;
1634
-
1635
- /**
1636
- * i40e_dbg_netdev_ops_read - read for netdev_ops datum
1637
- * @filp: the opened file
1638
- * @buffer: where to write the data for the user to read
1639
- * @count: the size of the user's buffer
1640
- * @ppos: file position offset
1641
- **/
1642
- static ssize_t i40e_dbg_netdev_ops_read (struct file * filp , char __user * buffer ,
1643
- size_t count , loff_t * ppos )
1644
- {
1645
- struct i40e_pf * pf = filp -> private_data ;
1646
- struct i40e_vsi * main_vsi ;
1647
- int bytes_not_copied ;
1648
- int buf_size = 256 ;
1649
- char * buf ;
1650
- int len ;
1651
-
1652
- /* don't allow partal reads */
1653
- if (* ppos != 0 )
1654
- return 0 ;
1655
- if (count < buf_size )
1656
- return - ENOSPC ;
1657
-
1658
- buf = kzalloc (buf_size , GFP_KERNEL );
1659
- if (!buf )
1660
- return - ENOSPC ;
1661
-
1662
- main_vsi = i40e_pf_get_main_vsi (pf );
1663
- len = snprintf (buf , buf_size , "%s: %s\n" , main_vsi -> netdev -> name ,
1664
- i40e_dbg_netdev_ops_buf );
1665
-
1666
- bytes_not_copied = copy_to_user (buffer , buf , len );
1667
- kfree (buf );
1668
-
1669
- if (bytes_not_copied )
1670
- return - EFAULT ;
1671
-
1672
- * ppos = len ;
1673
- return len ;
1674
- }
1675
1590
1676
1591
/**
1677
1592
* i40e_dbg_netdev_ops_write - write into netdev_ops datum
@@ -1685,35 +1600,36 @@ static ssize_t i40e_dbg_netdev_ops_write(struct file *filp,
1685
1600
size_t count , loff_t * ppos )
1686
1601
{
1687
1602
struct i40e_pf * pf = filp -> private_data ;
1603
+ char * cmd_buf , * buf_tmp ;
1688
1604
int bytes_not_copied ;
1689
1605
struct i40e_vsi * vsi ;
1690
- char * buf_tmp ;
1691
1606
int vsi_seid ;
1692
1607
int i , cnt ;
1693
1608
1694
1609
/* don't allow partial writes */
1695
1610
if (* ppos != 0 )
1696
1611
return 0 ;
1697
- if (count >= sizeof (i40e_dbg_netdev_ops_buf ))
1698
- return - ENOSPC ;
1699
1612
1700
- memset (i40e_dbg_netdev_ops_buf , 0 , sizeof (i40e_dbg_netdev_ops_buf ));
1701
- bytes_not_copied = copy_from_user (i40e_dbg_netdev_ops_buf ,
1702
- buffer , count );
1703
- if (bytes_not_copied )
1613
+ cmd_buf = kzalloc (count + 1 , GFP_KERNEL );
1614
+ if (!cmd_buf )
1615
+ return count ;
1616
+ bytes_not_copied = copy_from_user (cmd_buf , buffer , count );
1617
+ if (bytes_not_copied ) {
1618
+ kfree (cmd_buf );
1704
1619
return - EFAULT ;
1705
- i40e_dbg_netdev_ops_buf [count ] = '\0' ;
1620
+ }
1621
+ cmd_buf [count ] = '\0' ;
1706
1622
1707
- buf_tmp = strchr (i40e_dbg_netdev_ops_buf , '\n' );
1623
+ buf_tmp = strchr (cmd_buf , '\n' );
1708
1624
if (buf_tmp ) {
1709
1625
* buf_tmp = '\0' ;
1710
- count = buf_tmp - i40e_dbg_netdev_ops_buf + 1 ;
1626
+ count = buf_tmp - cmd_buf + 1 ;
1711
1627
}
1712
1628
1713
- if (strncmp (i40e_dbg_netdev_ops_buf , "change_mtu" , 10 ) == 0 ) {
1629
+ if (strncmp (cmd_buf , "change_mtu" , 10 ) == 0 ) {
1714
1630
int mtu ;
1715
1631
1716
- cnt = sscanf (& i40e_dbg_netdev_ops_buf [11 ], "%i %i" ,
1632
+ cnt = sscanf (& cmd_buf [11 ], "%i %i" ,
1717
1633
& vsi_seid , & mtu );
1718
1634
if (cnt != 2 ) {
1719
1635
dev_info (& pf -> pdev -> dev , "change_mtu <vsi_seid> <mtu>\n" );
@@ -1735,8 +1651,8 @@ static ssize_t i40e_dbg_netdev_ops_write(struct file *filp,
1735
1651
dev_info (& pf -> pdev -> dev , "Could not acquire RTNL - please try again\n" );
1736
1652
}
1737
1653
1738
- } else if (strncmp (i40e_dbg_netdev_ops_buf , "set_rx_mode" , 11 ) == 0 ) {
1739
- cnt = sscanf (& i40e_dbg_netdev_ops_buf [11 ], "%i" , & vsi_seid );
1654
+ } else if (strncmp (cmd_buf , "set_rx_mode" , 11 ) == 0 ) {
1655
+ cnt = sscanf (& cmd_buf [11 ], "%i" , & vsi_seid );
1740
1656
if (cnt != 1 ) {
1741
1657
dev_info (& pf -> pdev -> dev , "set_rx_mode <vsi_seid>\n" );
1742
1658
goto netdev_ops_write_done ;
@@ -1756,8 +1672,8 @@ static ssize_t i40e_dbg_netdev_ops_write(struct file *filp,
1756
1672
dev_info (& pf -> pdev -> dev , "Could not acquire RTNL - please try again\n" );
1757
1673
}
1758
1674
1759
- } else if (strncmp (i40e_dbg_netdev_ops_buf , "napi" , 4 ) == 0 ) {
1760
- cnt = sscanf (& i40e_dbg_netdev_ops_buf [4 ], "%i" , & vsi_seid );
1675
+ } else if (strncmp (cmd_buf , "napi" , 4 ) == 0 ) {
1676
+ cnt = sscanf (& cmd_buf [4 ], "%i" , & vsi_seid );
1761
1677
if (cnt != 1 ) {
1762
1678
dev_info (& pf -> pdev -> dev , "napi <vsi_seid>\n" );
1763
1679
goto netdev_ops_write_done ;
@@ -1775,21 +1691,20 @@ static ssize_t i40e_dbg_netdev_ops_write(struct file *filp,
1775
1691
dev_info (& pf -> pdev -> dev , "napi called\n" );
1776
1692
}
1777
1693
} else {
1778
- dev_info (& pf -> pdev -> dev , "unknown command '%s'\n" ,
1779
- i40e_dbg_netdev_ops_buf );
1694
+ dev_info (& pf -> pdev -> dev , "unknown command '%s'\n" , cmd_buf );
1780
1695
dev_info (& pf -> pdev -> dev , "available commands\n" );
1781
1696
dev_info (& pf -> pdev -> dev , " change_mtu <vsi_seid> <mtu>\n" );
1782
1697
dev_info (& pf -> pdev -> dev , " set_rx_mode <vsi_seid>\n" );
1783
1698
dev_info (& pf -> pdev -> dev , " napi <vsi_seid>\n" );
1784
1699
}
1785
1700
netdev_ops_write_done :
1701
+ kfree (cmd_buf );
1786
1702
return count ;
1787
1703
}
1788
1704
1789
1705
static const struct file_operations i40e_dbg_netdev_ops_fops = {
1790
1706
.owner = THIS_MODULE ,
1791
1707
.open = simple_open ,
1792
- .read = i40e_dbg_netdev_ops_read ,
1793
1708
.write = i40e_dbg_netdev_ops_write ,
1794
1709
};
1795
1710
0 commit comments