]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0) |
2 | * Copyright(c) 2018-2019 Pensando Systems, Inc. All rights reserved. | |
3 | */ | |
4 | ||
5 | #include <stdbool.h> | |
6 | ||
7 | #include "ionic_mac_api.h" | |
8 | ||
9 | int32_t | |
10 | ionic_init_mac(struct ionic_hw *hw) | |
11 | { | |
12 | int err = 0; | |
13 | ||
14 | IONIC_PRINT_CALL(); | |
15 | ||
16 | /* | |
17 | * Set the mac type | |
18 | */ | |
19 | ionic_set_mac_type(hw); | |
20 | ||
21 | switch (hw->mac.type) { | |
22 | case IONIC_MAC_CAPRI: | |
23 | break; | |
24 | default: | |
25 | err = -EINVAL; | |
26 | break; | |
27 | } | |
28 | ||
29 | return err; | |
30 | } | |
31 | ||
32 | int32_t | |
33 | ionic_set_mac_type(struct ionic_hw *hw) | |
34 | { | |
35 | int err = 0; | |
36 | ||
37 | IONIC_PRINT_CALL(); | |
38 | ||
39 | if (hw->vendor_id != IONIC_PENSANDO_VENDOR_ID) { | |
40 | IONIC_PRINT(ERR, "Unsupported vendor id: %" PRIx32 "", | |
41 | hw->vendor_id); | |
42 | return -EINVAL; | |
43 | } | |
44 | ||
45 | switch (hw->device_id) { | |
46 | case IONIC_DEV_ID_ETH_PF: | |
47 | case IONIC_DEV_ID_ETH_VF: | |
48 | case IONIC_DEV_ID_ETH_MGMT: | |
49 | hw->mac.type = IONIC_MAC_CAPRI; | |
50 | break; | |
51 | default: | |
52 | err = -EINVAL; | |
53 | IONIC_PRINT(ERR, "Unsupported device id: %" PRIx32 "", | |
54 | hw->device_id); | |
55 | break; | |
56 | } | |
57 | ||
58 | IONIC_PRINT(INFO, "Mac: %d (%d)", | |
59 | hw->mac.type, err); | |
60 | ||
61 | return err; | |
62 | } | |
63 |