net/ionic: register and initialize adapter
[dpdk.git] / drivers / net / ionic / ionic_mac_api.c
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 "ionic_mac_api.h"
6
7 int32_t
8 ionic_init_mac(struct ionic_hw *hw)
9 {
10         int err = 0;
11
12         IONIC_PRINT_CALL();
13
14         /*
15          * Set the mac type
16          */
17         ionic_set_mac_type(hw);
18
19         switch (hw->mac.type) {
20         case IONIC_MAC_CAPRI:
21                 break;
22         default:
23                 err = -EINVAL;
24                 break;
25         }
26
27         return err;
28 }
29
30 int32_t
31 ionic_set_mac_type(struct ionic_hw *hw)
32 {
33         int err = 0;
34
35         IONIC_PRINT_CALL();
36
37         if (hw->vendor_id != IONIC_PENSANDO_VENDOR_ID) {
38                 IONIC_PRINT(ERR, "Unsupported vendor id: %" PRIx32 "",
39                         hw->vendor_id);
40                 return -EINVAL;
41         }
42
43         switch (hw->device_id) {
44         case IONIC_DEV_ID_ETH_PF:
45         case IONIC_DEV_ID_ETH_VF:
46         case IONIC_DEV_ID_ETH_MGMT:
47                 hw->mac.type = IONIC_MAC_CAPRI;
48                 break;
49         default:
50                 err = -EINVAL;
51                 IONIC_PRINT(ERR, "Unsupported device id: %" PRIx32 "",
52                         hw->device_id);
53                 break;
54         }
55
56         IONIC_PRINT(INFO, "Mac: %d (%d)",
57                 hw->mac.type, err);
58
59         return err;
60 }
61