<commit_before>/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
 * Copyright (c) 2015-2018 Cavium Inc.
 * All rights reserved.
 * www.cavium.com
 */

#include "bnx2x.h"
#include "bnx2x_rxtx.h"

#include <rte_string_fns.h>
#include <rte_dev.h>
#include <rte_ethdev_pci.h>
#include <rte_alarm.h>

int bnx2x_logtype_init;
int bnx2x_logtype_driver;

/*
 * The set of PCI devices this driver supports
 */
#define BROADCOM_PCI_VENDOR_ID 0x14E4
static const struct rte_pci_id pci_id_bnx2x_map[] = {
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57800) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57711) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57810) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57811) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_OBS) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_4_10) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_2_20) },
#ifdef RTE_LIBRTE_BNX2X_MF_SUPPORT
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57810_MF) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57811_MF) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_MF) },
#endif
	{ .vendor_id = 0, }
};

static const struct rte_pci_id pci_id_bnx2xvf_map[] = {
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57800_VF) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57810_VF) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57811_VF) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_VF) },
	{ .vendor_id = 0, }
};

struct rte_bnx2x_xstats_name_off {
	char name[RTE_ETH_XSTATS_NAME_SIZE];
	uint32_t offset_hi;
	uint32_t offset_lo;
};

static const struct rte_bnx2x_xstats_name_off bnx2x_xstats_strings[] = {
	{"rx_buffer_drops",
		offsetof(struct bnx2x_eth_stats, brb_drop_hi),
		offsetof(struct bnx2x_eth_stats, brb_drop_lo)},
	{"rx_buffer_truncates",
		offsetof(struct bnx2x_eth_stats, brb_truncate_hi),
		offsetof(struct bnx2x_eth_stats, brb_truncate_lo)},
	{"rx_buffer_truncate_discard",
		offsetof(struct bnx2x_eth_stats, brb_truncate_discard),
		offsetof(struct bnx2x_eth_stats, brb_truncate_discard)},
	{"mac_filter_discard",
		offsetof(struct bnx2x_eth_stats, mac_filter_discard),
		offsetof(struct bnx2x_eth_stats, mac_filter_discard)},
	{"no_match_vlan_tag_discard",
		offsetof(struct bnx2x_eth_stats, mf_tag_discard),
		offsetof(struct bnx2x_eth_stats, mf_tag_discard)},
	{"tx_pause",
		offsetof(struct bnx2x_eth_stats, pause_frames_sent_hi),
		offsetof(struct bnx2x_eth_stats, pause_frames_sent_lo)},
	{"rx_pause",
		offsetof(struct bnx2x_eth_stats, pause_frames_received_hi),
		offsetof(struct bnx2x_eth_stats, pause_frames_received_lo)},
	{"tx_priority_flow_control",
		offsetof(struct bnx2x_eth_stats, pfc_frames_sent_hi),
		offsetof(struct bnx2x_eth_stats, pfc_frames_sent_lo)},
	{"rx_priority_flow_control",
		offsetof(struct bnx2x_eth_stats, pfc_frames_received_hi),
		offsetof(struct bnx2x_eth_stats, pfc_frames_received_lo)}
};

static int
bnx2x_link_update(struct rte_eth_dev *dev)
{
	struct bnx2x_softc *sc = dev->data->dev_private;
	struct rte_eth_link link;

	PMD_INIT_FUNC_TRACE(sc);

	bnx2x_link_status_update(sc);
	memset(&link, 0, sizeof(link));
	mb();
	link.link_speed = sc->link_vars.line_speed;
	switch (sc->link_vars.duplex) {
		case DUPLEX_FULL:<commit_msg>net/bnx2x: fix link state<commit_after>/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
 * Copyright (c) 2015-2018 Cavium Inc.
 * All rights reserved.
 * www.<EMAIL>
 */

#include "bnx2x.h"
#include "bnx2x_rxtx.h"

#include <rte_string_fns.h>
#include <rte_dev.h>
#include <rte_ethdev_pci.h>
#include <rte_alarm.h>

int bnx2x_logtype_init;
int bnx2x_logtype_driver;

/*
 * The set of PCI devices this driver supports
 */
#define BROADCOM_PCI_VENDOR_ID 0x14E4
static const struct rte_pci_id pci_id_bnx2x_map[] = {
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57800) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57711) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57810) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57811) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_OBS) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_4_10) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_2_20) },
#ifdef RTE_LIBRTE_BNX2X_MF_SUPPORT
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57810_MF) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57811_MF) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_MF) },
#endif
	{ .vendor_id = 0, }
};

static const struct rte_pci_id pci_id_bnx2xvf_map[] = {
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57800_VF) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57810_VF) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57811_VF) },
	{ RTE_PCI_DEVICE(BROADCOM_PCI_VENDOR_ID, CHIP_NUM_57840_VF) },
	{ .vendor_id = 0, }
};

struct rte_bnx2x_xstats_name_off {
	char name[RTE_ETH_XSTATS_NAME_SIZE];
	uint32_t offset_hi;
	uint32_t offset_lo;
};

static const struct rte_bnx2x_xstats_name_off bnx2x_xstats_strings[] = {
	{"rx_buffer_drops",
		offsetof(struct bnx2x_eth_stats, brb_drop_hi),
		offsetof(struct bnx2x_eth_stats, brb_drop_lo)},
	{"rx_buffer_truncates",
		offsetof(struct bnx2x_eth_stats, brb_truncate_hi),
		offsetof(struct bnx2x_eth_stats, brb_truncate_lo)},
	{"rx_buffer_truncate_discard",
		offsetof(struct bnx2x_eth_stats, brb_truncate_discard),
		offsetof(struct bnx2x_eth_stats, brb_truncate_discard)},
	{"mac_filter_discard",
		offsetof(struct bnx2x_eth_stats, mac_filter_discard),
		offsetof(struct bnx2x_eth_stats, mac_filter_discard)},
	{"no_match_vlan_tag_discard",
		offsetof(struct bnx2x_eth_stats, mf_tag_discard),
		offsetof(struct bnx2x_eth_stats, mf_tag_discard)},
	{"tx_pause",
		offsetof(struct bnx2x_eth_stats, pause_frames_sent_hi),
		offsetof(struct bnx2x_eth_stats, pause_frames_sent_lo)},
	{"rx_pause",
		offsetof(struct bnx2x_eth_stats, pause_frames_received_hi),
		offsetof(struct bnx2x_eth_stats, pause_frames_received_lo)},
	{"tx_priority_flow_control",
		offsetof(struct bnx2x_eth_stats, pfc_frames_sent_hi),
		offsetof(struct bnx2x_eth_stats, pfc_frames_sent_lo)},
	{"rx_priority_flow_control",
		offsetof(struct bnx2x_eth_stats, pfc_frames_received_hi),
		offsetof(struct bnx2x_eth_stats, pfc_frames_received_lo)}
};

static int
bnx2x_link_update(struct rte_eth_dev *dev)
{
	struct bnx2x_softc *sc = dev->data->dev_private;
	struct rte_eth_link link;

	PMD_INIT_FUNC_TRACE(sc);

	memset(&link, 0, sizeof(link));
	mb();
	link.link_speed = sc->link_vars.line_speed;
	switch (sc->link_vars.duplex) {
		case DUPLEX_FULL:
{'fraction_non_alphanumeric': 0.1015531660692951, 'fraction_numerical': 0.04032258064516129, 'mean_word_length': 8.074525745257452, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2114182', 'n_tokens_mistral': 3165, 'n_tokens_neox': 3037, 'n_words': 383}