File: ionic_mac_api.c

package info (click to toggle)
dpdk 25.11-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 127,892 kB
  • sloc: ansic: 2,358,479; python: 16,426; sh: 4,474; makefile: 1,713; awk: 70
file content (62 lines) | stat: -rw-r--r-- 976 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright 2018-2022 Advanced Micro Devices, Inc.
 */

#include <stdbool.h>

#include "ionic_mac_api.h"

int32_t
ionic_init_mac(struct ionic_hw *hw)
{
	int err = 0;

	IONIC_PRINT_CALL();

	/*
	 * Set the mac type
	 */
	ionic_set_mac_type(hw);

	switch (hw->mac.type) {
	case IONIC_MAC_CAPRI:
		break;
	default:
		err = -EINVAL;
		break;
	}

	return err;
}

int32_t
ionic_set_mac_type(struct ionic_hw *hw)
{
	int err = 0;

	IONIC_PRINT_CALL();

	if (hw->vendor_id != IONIC_PENSANDO_VENDOR_ID) {
		IONIC_PRINT(ERR, "Unsupported vendor id: %" PRIx32 "",
			hw->vendor_id);
		return -EINVAL;
	}

	switch (hw->device_id) {
	case IONIC_DEV_ID_ETH_PF:
	case IONIC_DEV_ID_ETH_VF:
	case IONIC_DEV_ID_ETH_MGMT:
		hw->mac.type = IONIC_MAC_CAPRI;
		break;
	default:
		err = -EINVAL;
		IONIC_PRINT(ERR, "Unsupported device id: %" PRIx32 "",
			hw->device_id);
		break;
	}

	IONIC_PRINT(INFO, "Mac: %d (%d)",
		hw->mac.type, err);

	return err;
}