Commit | Line | Data |
---|---|---|
0e7b3644 AD |
1 | /* Intel Ethernet Switch Host Interface Driver |
2 | * Copyright(c) 2013 - 2014 Intel Corporation. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms and conditions of the GNU General Public License, | |
6 | * version 2, as published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope it will be useful, but WITHOUT | |
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
11 | * more details. | |
12 | * | |
13 | * The full GNU General Public License is included in this distribution in | |
14 | * the file called "COPYING". | |
15 | * | |
16 | * Contact Information: | |
17 | * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> | |
18 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | |
19 | */ | |
20 | ||
21 | #include "fm10k.h" | |
22 | ||
23 | static netdev_tx_t fm10k_xmit_frame(struct sk_buff *skb, struct net_device *dev) | |
24 | { | |
25 | dev_kfree_skb_any(skb); | |
26 | return NETDEV_TX_OK; | |
27 | } | |
28 | ||
29 | static int fm10k_change_mtu(struct net_device *dev, int new_mtu) | |
30 | { | |
31 | if (new_mtu < 68 || new_mtu > FM10K_MAX_JUMBO_FRAME_SIZE) | |
32 | return -EINVAL; | |
33 | ||
34 | dev->mtu = new_mtu; | |
35 | ||
36 | return 0; | |
37 | } | |
38 | ||
39 | static int fm10k_set_mac(struct net_device *dev, void *p) | |
40 | { | |
41 | struct sockaddr *addr = p; | |
42 | s32 err = 0; | |
43 | ||
44 | if (!is_valid_ether_addr(addr->sa_data)) | |
45 | return -EADDRNOTAVAIL; | |
46 | ||
47 | if (!err) { | |
48 | ether_addr_copy(dev->dev_addr, addr->sa_data); | |
49 | dev->addr_assign_type &= ~NET_ADDR_RANDOM; | |
50 | } | |
51 | ||
52 | return err; | |
53 | } | |
54 | ||
55 | static void fm10k_set_rx_mode(struct net_device *dev) | |
56 | { | |
57 | } | |
58 | ||
59 | static const struct net_device_ops fm10k_netdev_ops = { | |
60 | .ndo_validate_addr = eth_validate_addr, | |
61 | .ndo_start_xmit = fm10k_xmit_frame, | |
62 | .ndo_set_mac_address = fm10k_set_mac, | |
63 | .ndo_change_mtu = fm10k_change_mtu, | |
64 | .ndo_set_rx_mode = fm10k_set_rx_mode, | |
65 | }; | |
66 | ||
67 | #define DEFAULT_DEBUG_LEVEL_SHIFT 3 | |
68 | ||
69 | struct net_device *fm10k_alloc_netdev(void) | |
70 | { | |
71 | struct fm10k_intfc *interface; | |
72 | struct net_device *dev; | |
73 | ||
74 | dev = alloc_etherdev(sizeof(struct fm10k_intfc)); | |
75 | if (!dev) | |
76 | return NULL; | |
77 | ||
78 | /* set net device and ethtool ops */ | |
79 | dev->netdev_ops = &fm10k_netdev_ops; | |
80 | ||
81 | /* configure default debug level */ | |
82 | interface = netdev_priv(dev); | |
83 | interface->msg_enable = (1 << DEFAULT_DEBUG_LEVEL_SHIFT) - 1; | |
84 | ||
85 | /* configure default features */ | |
86 | dev->features |= NETIF_F_SG; | |
87 | ||
88 | /* all features defined to this point should be changeable */ | |
89 | dev->hw_features |= dev->features; | |
90 | ||
91 | /* configure VLAN features */ | |
92 | dev->vlan_features |= dev->features; | |
93 | ||
94 | /* configure tunnel offloads */ | |
95 | dev->hw_enc_features = NETIF_F_SG; | |
96 | ||
97 | return dev; | |
98 | } |