path: root/internal.h
diff options
authorBen Hutchings <>2011-10-29 02:33:30 +0100
committerBen Hutchings <>2011-11-01 16:50:58 +0000
commit37897ca86845ac9f8df16ca424477baa3ac8c389 (patch)
tree5152407cc257e06f5fa14b88bfcc5c1719da0d33 /internal.h
parent3393b8366dbfa7717e41072481d34a48a2f426b3 (diff)
Encapsulate command context in a structure
Replace the fd and ifr arguments to each sub-command handler with struct cmd_context. Change send_ioctl() to take a pointer to this context and a pointer to the ethtool_cmd or other structure. Use send_ioctl() consistently. Signed-off-by: Ben Hutchings <>
Diffstat (limited to 'internal.h')
1 files changed, 12 insertions, 4 deletions
diff --git a/internal.h b/internal.h
index 2b6a54a..c2f504a 100644
--- a/internal.h
+++ b/internal.h
@@ -88,6 +88,14 @@ static inline int test_bit(unsigned int nr, const unsigned long *addr)
#define RX_CLS_LOC_UNSPEC 0xffffffffUL
+/* Context for sub-commands */
+struct cmd_context {
+ int fd; /* socket suitable for ethtool ioctl */
+ struct ifreq ifr; /* ifreq suitable for ethtool ioctl */
+int send_ioctl(struct cmd_context *ctx, void *cmd);
/* National Semiconductor DP83815, DP83816 */
int natsemi_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
int natsemi_dump_eeprom(struct ethtool_drvinfo *info,
@@ -155,10 +163,10 @@ int st_gmac_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
/* Rx flow classification */
int rxclass_parse_ruleopts(char **optstr, int opt_cnt,
struct ethtool_rx_flow_spec *fsp);
-int rxclass_rule_getall(int fd, struct ifreq *ifr);
-int rxclass_rule_get(int fd, struct ifreq *ifr, __u32 loc);
-int rxclass_rule_ins(int fd, struct ifreq *ifr,
+int rxclass_rule_getall(struct cmd_context *ctx);
+int rxclass_rule_get(struct cmd_context *ctx, __u32 loc);
+int rxclass_rule_ins(struct cmd_context *ctx,
struct ethtool_rx_flow_spec *fsp);
-int rxclass_rule_del(int fd, struct ifreq *ifr, __u32 loc);
+int rxclass_rule_del(struct cmd_context *ctx, __u32 loc);
#endif /* ETHTOOL_INTERNAL_H__ */