hpi_pfc.c revision 63b1987d5d7387bda49397c0f3f063b49651a5bc
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * CDDL HEADER START
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The contents of this file are subject to the terms of the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Common Development and Distribution License (the "License").
199767f8919635c4928607450d9e0abb932109ceToomas Soome * You may not use this file except in compliance with the License.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * or http://www.opensolaris.org/os/licensing.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * See the License for the specific language governing permissions
199767f8919635c4928607450d9e0abb932109ceToomas Soome * and limitations under the License.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * When distributing Covered Code, include this CDDL HEADER in each
199767f8919635c4928607450d9e0abb932109ceToomas Soome * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * If applicable, add the following below this CDDL HEADER, with the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * fields enclosed by brackets "[]" replaced with your own identifying
199767f8919635c4928607450d9e0abb932109ceToomas Soome * information: Portions Copyright [yyyy] [name of copyright owner]
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * CDDL HEADER END
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Use is subject to license terms.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <hxge_impl.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <hpi_pfc.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define TCAM_COMPLETION_TRY_COUNT 10
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define HXGE_VLAN_TABLE_ENTRIES 128
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define HXGE_PFC_INT_STATUS_CLEAR 0x7ULL
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestatic uint64_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_tcam_check_completion(hpi_handle_t handle, tcam_op_t op_type)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint32_t try_counter, tcam_delay = 10;
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_tcam_ctrl_t tctl;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome try_counter = TCAM_COMPLETION_TRY_COUNT;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome switch (op_type) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome case TCAM_RWC_STAT:
199767f8919635c4928607450d9e0abb932109ceToomas Soome READ_TCAM_REG_CTL(handle, &tctl.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome while ((try_counter) &&
199767f8919635c4928607450d9e0abb932109ceToomas Soome (tctl.bits.status != TCAM_CTL_RWC_RWC_STAT)) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome try_counter--;
199767f8919635c4928607450d9e0abb932109ceToomas Soome HXGE_DELAY(tcam_delay);
199767f8919635c4928607450d9e0abb932109ceToomas Soome READ_TCAM_REG_CTL(handle, &tctl.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome }
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (!try_counter) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome HPI_ERROR_MSG((handle.function, HPI_ERR_CTL,
199767f8919635c4928607450d9e0abb932109ceToomas Soome " TCAM RWC_STAT operation"
199767f8919635c4928607450d9e0abb932109ceToomas Soome " failed to complete \n"));
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_PFC_TCAM_HW_ERROR);
199767f8919635c4928607450d9e0abb932109ceToomas Soome }
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome tctl.value = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome break;
199767f8919635c4928607450d9e0abb932109ceToomas Soome case TCAM_RWC_MATCH:
199767f8919635c4928607450d9e0abb932109ceToomas Soome READ_TCAM_REG_CTL(handle, &tctl.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome while ((try_counter) &&
199767f8919635c4928607450d9e0abb932109ceToomas Soome (tctl.bits.match != TCAM_CTL_RWC_RWC_MATCH)) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome try_counter--;
199767f8919635c4928607450d9e0abb932109ceToomas Soome HXGE_DELAY(tcam_delay);
199767f8919635c4928607450d9e0abb932109ceToomas Soome READ_TCAM_REG_CTL(handle, &tctl.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome }
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (!try_counter) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome HPI_ERROR_MSG((handle.function, HPI_ERR_CTL,
199767f8919635c4928607450d9e0abb932109ceToomas Soome " TCAM Match operationfailed to find match \n"));
199767f8919635c4928607450d9e0abb932109ceToomas Soome }
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome break;
199767f8919635c4928607450d9e0abb932109ceToomas Soome default:
199767f8919635c4928607450d9e0abb932109ceToomas Soome HPI_ERROR_MSG((handle.function, HPI_ERR_CTL,
199767f8919635c4928607450d9e0abb932109ceToomas Soome " Invalid TCAM completion Request \n"));
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_PFC_ERROR | HPI_TCAM_ERROR | OPCODE_INVALID);
199767f8919635c4928607450d9e0abb932109ceToomas Soome }
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (tctl.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_tcam_entry_read(hpi_handle_t handle, uint32_t location,
199767f8919635c4928607450d9e0abb932109ceToomas Soome hxge_tcam_entry_t *tcam_ptr)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_tcam_ctrl_t tctl;
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_tcam_ctrl_t tctl_rv;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Hydra doesn't allow to read TCAM entries. Use compare instead.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome WRITE_TCAM_REG_MASK0(handle, tcam_ptr->mask0);
199767f8919635c4928607450d9e0abb932109ceToomas Soome WRITE_TCAM_REG_MASK1(handle, tcam_ptr->mask1);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome WRITE_TCAM_REG_KEY0(handle, tcam_ptr->key0);
199767f8919635c4928607450d9e0abb932109ceToomas Soome WRITE_TCAM_REG_KEY1(handle, tcam_ptr->key1);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome tctl.value = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome tctl.bits.addr = location;
199767f8919635c4928607450d9e0abb932109ceToomas Soome tctl.bits.cmd = TCAM_CTL_RWC_TCAM_CMP;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome WRITE_TCAM_REG_CTL(handle, tctl.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome tctl_rv.value = hpi_pfc_tcam_check_completion(handle, TCAM_RWC_MATCH);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (tctl_rv.bits.match)
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_FAILURE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_tcam_asc_ram_entry_read(hpi_handle_t handle,
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint32_t location, uint64_t *ram_data)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t tcam_stat;
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_tcam_ctrl_t tctl;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome tctl.value = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome tctl.bits.addr = location;
199767f8919635c4928607450d9e0abb932109ceToomas Soome tctl.bits.cmd = TCAM_CTL_RWC_RAM_RD;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome WRITE_TCAM_REG_CTL(handle, tctl.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcam_stat = hpi_pfc_tcam_check_completion(handle, TCAM_RWC_STAT);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (tcam_stat & HPI_FAILURE) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome HPI_ERROR_MSG((handle.function, HPI_ERR_CTL,
199767f8919635c4928607450d9e0abb932109ceToomas Soome "TCAM RAM read failed loc %d \n", location));
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_PFC_ASC_RAM_RD_ERROR);
199767f8919635c4928607450d9e0abb932109ceToomas Soome }
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome READ_TCAM_REG_KEY0(handle, ram_data);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_tcam_asc_ram_entry_write(hpi_handle_t handle, uint32_t location,
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t ram_data)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t tcam_stat = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_tcam_ctrl_t tctl;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome WRITE_TCAM_REG_KEY0(handle, ram_data);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome tctl.value = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome tctl.bits.addr = location;
199767f8919635c4928607450d9e0abb932109ceToomas Soome tctl.bits.cmd = TCAM_CTL_RWC_RAM_WR;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome HPI_DEBUG_MSG((handle.function, HPI_PFC_CTL,
199767f8919635c4928607450d9e0abb932109ceToomas Soome " tcam ascr write: location %x data %llx ctl value %llx \n",
199767f8919635c4928607450d9e0abb932109ceToomas Soome location, ram_data, tctl.value));
199767f8919635c4928607450d9e0abb932109ceToomas Soome WRITE_TCAM_REG_CTL(handle, tctl.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcam_stat = hpi_pfc_tcam_check_completion(handle, TCAM_RWC_STAT);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (tcam_stat & HPI_FAILURE) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome HPI_ERROR_MSG((handle.function, HPI_ERR_CTL,
199767f8919635c4928607450d9e0abb932109ceToomas Soome "TCAM RAM write failed loc %d \n", location));
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_PFC_ASC_RAM_WR_ERROR);
199767f8919635c4928607450d9e0abb932109ceToomas Soome }
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestatic hpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_set_config(hpi_handle_t handle, pfc_config_t config)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_CONFIG;
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, offset, config.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestatic hpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_get_config(hpi_handle_t handle, pfc_config_t *configp)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_CONFIG;
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_READ64(handle, offset, &configp->value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_set_tcam_enable(hpi_handle_t handle, boolean_t tcam)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_config_t config;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Read the register first.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome (void) hpi_pfc_get_config(handle, &config);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (tcam)
199767f8919635c4928607450d9e0abb932109ceToomas Soome config.bits.tcam_en = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome config.bits.tcam_en = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (hpi_pfc_set_config(handle, config));
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_set_l2_hash(hpi_handle_t handle, boolean_t l2_hash)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_config_t config;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Read the register first.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome (void) hpi_pfc_get_config(handle, &config);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (l2_hash)
199767f8919635c4928607450d9e0abb932109ceToomas Soome config.bits.l2_hash_en = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome config.bits.l2_hash_en = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (hpi_pfc_set_config(handle, config));
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_set_tcp_cksum(hpi_handle_t handle, boolean_t cksum)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_config_t config;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Read the register first.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome (void) hpi_pfc_get_config(handle, &config);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (cksum)
199767f8919635c4928607450d9e0abb932109ceToomas Soome config.bits.tcp_cs_en = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome config.bits.tcp_cs_en = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (hpi_pfc_set_config(handle, config));
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_set_default_dma(hpi_handle_t handle, uint32_t dma_channel_no)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_config_t config;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome (void) hpi_pfc_get_config(handle, &config);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (dma_channel_no > PFC_MAX_DMA_CHANNELS)
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_FAILURE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome config.bits.default_dma = dma_channel_no;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (hpi_pfc_set_config(handle, config));
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_mac_addr_enable(hpi_handle_t handle, uint32_t slot)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_config_t config;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint32_t bit;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (slot >= PFC_N_MAC_ADDRESSES) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_FAILURE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome }
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome (void) hpi_pfc_get_config(handle, &config);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (slot < 24) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome bit = 1 << slot;
199767f8919635c4928607450d9e0abb932109ceToomas Soome config.bits.mac_addr_en_l = config.bits.mac_addr_en_l | bit;
199767f8919635c4928607450d9e0abb932109ceToomas Soome } else {
199767f8919635c4928607450d9e0abb932109ceToomas Soome bit = 1 << (slot - 24);
199767f8919635c4928607450d9e0abb932109ceToomas Soome config.bits.mac_addr_en = config.bits.mac_addr_en | bit;
199767f8919635c4928607450d9e0abb932109ceToomas Soome }
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (hpi_pfc_set_config(handle, config));
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_mac_addr_disable(hpi_handle_t handle, uint32_t slot)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_config_t config;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint32_t bit;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (slot >= PFC_N_MAC_ADDRESSES) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_FAILURE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome }
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome (void) hpi_pfc_get_config(handle, &config);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (slot < 24) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome bit = 1 << slot;
199767f8919635c4928607450d9e0abb932109ceToomas Soome config.bits.mac_addr_en_l = config.bits.mac_addr_en_l & ~bit;
199767f8919635c4928607450d9e0abb932109ceToomas Soome } else {
199767f8919635c4928607450d9e0abb932109ceToomas Soome bit = 1 << (slot - 24);
199767f8919635c4928607450d9e0abb932109ceToomas Soome config.bits.mac_addr_en = config.bits.mac_addr_en & ~bit;
199767f8919635c4928607450d9e0abb932109ceToomas Soome }
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (hpi_pfc_set_config(handle, config));
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_set_force_csum(hpi_handle_t handle, boolean_t force)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_config_t config;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome (void) hpi_pfc_get_config(handle, &config);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (force)
199767f8919635c4928607450d9e0abb932109ceToomas Soome config.bits.force_cs_en = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome config.bits.force_cs_en = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (hpi_pfc_set_config(handle, config));
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_cfg_vlan_table_clear(hpi_handle_t handle)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome int i;
199767f8919635c4928607450d9e0abb932109ceToomas Soome int offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome int step = 8;
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_vlan_table_t table_entry;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome table_entry.value = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome for (i = 0; i < HXGE_VLAN_TABLE_ENTRIES; i++) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome table_entry.bits.member = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_VLAN_TABLE + i * step;
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, offset, table_entry.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome }
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_cfg_vlan_table_entry_clear(hpi_handle_t handle, vlan_id_t vlan_id)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_vlan_table_t vlan_tbl_entry;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t bit;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Assumes that the hardware will generate the new parity
199767f8919635c4928607450d9e0abb932109ceToomas Soome * data.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_VLAN_REG_OFFSET(vlan_id);
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_READ64(handle, offset, (uint64_t *)&vlan_tbl_entry.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome bit = PFC_VLAN_BIT_OFFSET(vlan_id);
199767f8919635c4928607450d9e0abb932109ceToomas Soome bit = 1 << bit;
199767f8919635c4928607450d9e0abb932109ceToomas Soome vlan_tbl_entry.bits.member = vlan_tbl_entry.bits.member & ~bit;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, offset, vlan_tbl_entry.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_cfg_vlan_table_entry_set(hpi_handle_t handle, vlan_id_t vlan_id)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_vlan_table_t vlan_tbl_entry;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t bit;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Assumes that the hardware will generate the new parity
199767f8919635c4928607450d9e0abb932109ceToomas Soome * data.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_VLAN_REG_OFFSET(vlan_id);
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_READ64(handle, offset, (uint64_t *)&vlan_tbl_entry.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome bit = PFC_VLAN_BIT_OFFSET(vlan_id);
199767f8919635c4928607450d9e0abb932109ceToomas Soome bit = 1 << bit;
199767f8919635c4928607450d9e0abb932109ceToomas Soome vlan_tbl_entry.bits.member = vlan_tbl_entry.bits.member | bit;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, offset, vlan_tbl_entry.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_cfg_vlan_control_set(hpi_handle_t handle, boolean_t parity,
199767f8919635c4928607450d9e0abb932109ceToomas Soome boolean_t valid, vlan_id_t vlan_id)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_vlan_ctrl_t vlan_control;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome vlan_control.value = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (parity)
199767f8919635c4928607450d9e0abb932109ceToomas Soome vlan_control.bits.par_en = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome vlan_control.bits.par_en = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (valid)
199767f8919635c4928607450d9e0abb932109ceToomas Soome vlan_control.bits.valid = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome vlan_control.bits.valid = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome vlan_control.bits.id = vlan_id;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, PFC_VLAN_CTRL, vlan_control.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_get_vlan_parity_log(hpi_handle_t handle, pfc_vlan_par_err_log_t *logp)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_VLAN_PAR_ERR_LOG;
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_READ64(handle, offset, &logp->value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_set_mac_address(hpi_handle_t handle, uint32_t slot, uint64_t address)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t moffset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_mac_addr_mask_t mask;
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_mac_addr_t addr;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (slot >= PFC_N_MAC_ADDRESSES)
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_FAILURE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_MAC_ADDRESS(slot);
199767f8919635c4928607450d9e0abb932109ceToomas Soome moffset = PFC_MAC_ADDRESS_MASK(slot);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome addr.bits.addr = address >> 32;
199767f8919635c4928607450d9e0abb932109ceToomas Soome addr.bits.addr_l = address & 0xffffffff;
199767f8919635c4928607450d9e0abb932109ceToomas Soome mask.bits.mask = 0x0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome mask.bits.mask_l = 0x0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, offset, addr.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, moffset, mask.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (hpi_pfc_mac_addr_enable(handle, slot));
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_clear_mac_address(hpi_handle_t handle, uint32_t slot)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset, moffset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t zaddr = 0x0ULL;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t zmask = 0x0ULL;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (slot >= PFC_N_MAC_ADDRESSES)
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_FAILURE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome (void) hpi_pfc_mac_addr_disable(handle, slot);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_MAC_ADDRESS(slot);
199767f8919635c4928607450d9e0abb932109ceToomas Soome moffset = PFC_MAC_ADDRESS_MASK(slot);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, offset, zaddr);
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, moffset, zmask);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_clear_multicast_hash_table(hpi_handle_t handle, uint32_t slot)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (slot >= PFC_N_MAC_ADDRESSES)
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_FAILURE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_HASH_ADDR(slot);
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, offset, 0ULL);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_set_multicast_hash_table(hpi_handle_t handle, uint32_t slot,
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t address)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (slot >= PFC_N_MAC_ADDRESSES)
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_FAILURE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_HASH_ADDR(slot);
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, offset, address);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_set_l2_class_slot(hpi_handle_t handle, uint16_t etype, boolean_t valid,
199767f8919635c4928607450d9e0abb932109ceToomas Soome int slot)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_l2_class_config_t l2_config;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (slot >= PFC_N_MAC_ADDRESSES)
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_FAILURE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome l2_config.value = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (valid)
199767f8919635c4928607450d9e0abb932109ceToomas Soome l2_config.bits.valid = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome l2_config.bits.valid = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome l2_config.bits.etype = etype;
199767f8919635c4928607450d9e0abb932109ceToomas Soome l2_config.bits.rsrvd = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_L2_CONFIG(slot);
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, offset, l2_config.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_set_l3_class_config(hpi_handle_t handle, tcam_class_t slot,
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcam_key_cfg_t cfg)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_l3_class_config_t l3_config;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (slot >= PFC_N_MAC_ADDRESSES)
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_FAILURE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome l3_config.value = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (cfg.lookup_enable)
199767f8919635c4928607450d9e0abb932109ceToomas Soome l3_config.bits.tsel = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome l3_config.bits.tsel = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (cfg.discard)
199767f8919635c4928607450d9e0abb932109ceToomas Soome l3_config.bits.discard = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome l3_config.bits.discard = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_L3_CONFIG(slot);
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, offset, l3_config.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_get_l3_class_config(hpi_handle_t handle, tcam_class_t slot,
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcam_key_cfg_t *cfg)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_l3_class_config_t l3_config;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (slot >= PFC_N_MAC_ADDRESSES)
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_FAILURE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_L3_CONFIG(slot);
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_READ64(handle, offset, &l3_config.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (l3_config.bits.tsel)
199767f8919635c4928607450d9e0abb932109ceToomas Soome cfg->lookup_enable = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome cfg->lookup_enable = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (l3_config.bits.discard)
199767f8919635c4928607450d9e0abb932109ceToomas Soome cfg->discard = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome cfg->discard = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestatic hpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_set_tcam_control(hpi_handle_t handle, pfc_tcam_ctrl_t *tcontrolp)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_TCAM_CTRL;
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, offset, tcontrolp->value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_tcam_entry_invalidate(hpi_handle_t handle, uint32_t location)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome hxge_tcam_entry_t tcam_ptr;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome (void) memset(&tcam_ptr, 0, sizeof (hxge_tcam_entry_t));
199767f8919635c4928607450d9e0abb932109ceToomas Soome (void) hpi_pfc_tcam_entry_write(handle, location, &tcam_ptr);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_tcam_invalidate_all(hpi_handle_t handle)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome int i;
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_tcam_ctrl_t tcontrol;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcontrol.value = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome for (i = 0; i < PFC_N_TCAM_ENTRIES; i++) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome (void) hpi_pfc_set_tcam_control(handle, &tcontrol);
199767f8919635c4928607450d9e0abb932109ceToomas Soome (void) hpi_pfc_tcam_entry_invalidate(handle, i);
199767f8919635c4928607450d9e0abb932109ceToomas Soome }
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_tcam_entry_write(hpi_handle_t handle, uint32_t location,
199767f8919635c4928607450d9e0abb932109ceToomas Soome hxge_tcam_entry_t *tcam_ptr)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t tcam_stat;
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_tcam_ctrl_t tctl;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome WRITE_TCAM_REG_MASK0(handle, tcam_ptr->mask0);
199767f8919635c4928607450d9e0abb932109ceToomas Soome WRITE_TCAM_REG_MASK1(handle, tcam_ptr->mask1);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome WRITE_TCAM_REG_KEY0(handle, tcam_ptr->key0);
199767f8919635c4928607450d9e0abb932109ceToomas Soome WRITE_TCAM_REG_KEY1(handle, tcam_ptr->key1);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome HPI_DEBUG_MSG((handle.function, HPI_PFC_CTL,
199767f8919635c4928607450d9e0abb932109ceToomas Soome " tcam write: location %x\n key: %llx %llx\n mask: %llx %llx\n",
199767f8919635c4928607450d9e0abb932109ceToomas Soome location, tcam_ptr->key0, tcam_ptr->key1,
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcam_ptr->mask0, tcam_ptr->mask1));
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome tctl.value = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome tctl.bits.addr = location;
199767f8919635c4928607450d9e0abb932109ceToomas Soome tctl.bits.cmd = TCAM_CTL_RWC_TCAM_WR;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome HPI_DEBUG_MSG((handle.function, HPI_PFC_CTL,
199767f8919635c4928607450d9e0abb932109ceToomas Soome " tcam write: ctl value %llx \n", tctl.value));
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome WRITE_TCAM_REG_CTL(handle, tctl.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcam_stat = hpi_pfc_tcam_check_completion(handle, TCAM_RWC_STAT);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (tcam_stat & HPI_FAILURE) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome HPI_ERROR_MSG((handle.function, HPI_ERR_CTL,
199767f8919635c4928607450d9e0abb932109ceToomas Soome "TCAM Write failed loc %d \n", location));
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_PFC_TCAM_WR_ERROR);
199767f8919635c4928607450d9e0abb932109ceToomas Soome }
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_get_tcam_parity_log(hpi_handle_t handle, pfc_tcam_par_err_log_t *logp)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_TCAM_PAR_ERR_LOG;
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_READ64(handle, offset, &logp->value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_get_tcam_auto_init(hpi_handle_t handle, pfc_auto_init_t *autoinitp)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_AUTO_INIT;
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_READ64(handle, offset, &autoinitp->value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_set_tcp_control_discard(hpi_handle_t handle, boolean_t discard)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp_ctrl_mask_t tcp;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp.value = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = TCP_CTRL_MASK;
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_READ64(handle, offset, &tcp.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (discard)
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp.bits.discard = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp.bits.discard = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, offset, tcp.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_set_tcp_control_fin(hpi_handle_t handle, boolean_t fin)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp_ctrl_mask_t tcp;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp.value = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = TCP_CTRL_MASK;
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_READ64(handle, offset, &tcp.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (fin)
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp.bits.fin = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp.bits.fin = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, offset, tcp.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_set_tcp_control_syn(hpi_handle_t handle, boolean_t syn)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp_ctrl_mask_t tcp;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp.value = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = TCP_CTRL_MASK;
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_READ64(handle, offset, &tcp.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (syn)
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp.bits.syn = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp.bits.syn = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, offset, tcp.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_set_tcp_control_rst(hpi_handle_t handle, boolean_t rst)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp_ctrl_mask_t tcp;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp.value = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = TCP_CTRL_MASK;
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_READ64(handle, offset, &tcp.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (rst)
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp.bits.rst = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp.bits.rst = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, offset, tcp.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_set_tcp_control_psh(hpi_handle_t handle, boolean_t push)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp_ctrl_mask_t tcp;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp.value = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = TCP_CTRL_MASK;
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_READ64(handle, offset, &tcp.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (push)
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp.bits.psh = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp.bits.psh = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, offset, tcp.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_set_tcp_control_ack(hpi_handle_t handle, boolean_t ack)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp_ctrl_mask_t tcp;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp.value = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = TCP_CTRL_MASK;
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_READ64(handle, offset, &tcp.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (ack)
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp.bits.ack = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome tcp.bits.ack = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, offset, tcp.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_set_hash_seed_value(hpi_handle_t handle, uint32_t seed)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome src_hash_val_t src_hash_seed;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome src_hash_seed.value = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome src_hash_seed.bits.seed = seed;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = SRC_HASH_VAL;
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, offset, src_hash_seed.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_get_interrupt_status(hpi_handle_t handle, pfc_int_status_t *statusp)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_INT_STATUS;
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_READ64(handle, offset, &statusp->value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_clear_interrupt_status(hpi_handle_t handle)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_INT_STATUS;
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, offset, HXGE_PFC_INT_STATUS_CLEAR);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_set_interrupt_mask(hpi_handle_t handle, boolean_t drop,
199767f8919635c4928607450d9e0abb932109ceToomas Soome boolean_t tcam_parity_error, boolean_t vlan_parity_error)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_int_mask_t mask;
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome mask.value = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (drop)
199767f8919635c4928607450d9e0abb932109ceToomas Soome mask.bits.pkt_drop_mask = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome mask.bits.pkt_drop_mask = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (tcam_parity_error)
199767f8919635c4928607450d9e0abb932109ceToomas Soome mask.bits.tcam_parity_err_mask = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome mask.bits.tcam_parity_err_mask = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (vlan_parity_error)
199767f8919635c4928607450d9e0abb932109ceToomas Soome mask.bits.vlan_parity_err_mask = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome else
199767f8919635c4928607450d9e0abb932109ceToomas Soome mask.bits.vlan_parity_err_mask = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_INT_MASK;
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, offset, mask.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_get_drop_log(hpi_handle_t handle, pfc_drop_log_t *logp)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_DROP_LOG;
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_READ64(handle, offset, &logp->value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_set_drop_log_mask(hpi_handle_t handle, boolean_t vlan_drop,
199767f8919635c4928607450d9e0abb932109ceToomas Soome boolean_t tcam_drop, boolean_t class_code_drop, boolean_t l2_addr_drop,
199767f8919635c4928607450d9e0abb932109ceToomas Soome boolean_t tcp_ctrl_drop)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome pfc_drop_log_mask_t log;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome log.value = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (vlan_drop)
199767f8919635c4928607450d9e0abb932109ceToomas Soome log.bits.vlan_drop_mask = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (tcam_drop)
199767f8919635c4928607450d9e0abb932109ceToomas Soome log.bits.tcam_drop_mask = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (class_code_drop)
199767f8919635c4928607450d9e0abb932109ceToomas Soome log.bits.class_code_drop_mask = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (l2_addr_drop)
199767f8919635c4928607450d9e0abb932109ceToomas Soome log.bits.l2_addr_drop_mask = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (tcp_ctrl_drop)
199767f8919635c4928607450d9e0abb932109ceToomas Soome log.bits.tcp_ctrl_drop_mask = 1;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_DROP_LOG_MASK;
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_WRITE64(handle, offset, log.value);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_get_bad_csum_counter(hpi_handle_t handle, uint64_t *countp)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_BAD_CS_COUNTER;
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_READ64(handle, offset, countp);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_get_drop_counter(hpi_handle_t handle, uint64_t *countp)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint64_t offset;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome offset = PFC_DROP_COUNTER;
199767f8919635c4928607450d9e0abb932109ceToomas Soome REG_PIO_READ64(handle, offset, countp);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_get_number_mac_addrs(hpi_handle_t handle, uint32_t *n_of_addrs)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome HXGE_REG_RD32(handle, HCR_REG + HCR_N_MAC_ADDRS, n_of_addrs);
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_mac_addr_get_i(hpi_handle_t handle, uint8_t *data, int slot)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint32_t step = sizeof (uint32_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint32_t addr_hi = 0, addr_lo = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (slot >= PFC_N_MAC_ADDRESSES)
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_FAILURE);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome /*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Read the MAC address out of the SPROM at the blade's
199767f8919635c4928607450d9e0abb932109ceToomas Soome * specific location.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome HXGE_REG_RD32(handle, HCR_REG + HCR_ADDR_LO + slot * step, &addr_lo);
199767f8919635c4928607450d9e0abb932109ceToomas Soome HXGE_REG_RD32(handle, HCR_REG + HCR_ADDR_HI + slot * step, &addr_hi);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome data[0] = addr_lo & 0x000000ff;
199767f8919635c4928607450d9e0abb932109ceToomas Soome data[1] = (addr_lo & 0x0000ff00) >> 8;
199767f8919635c4928607450d9e0abb932109ceToomas Soome data[2] = (addr_lo & 0x00ff0000) >> 16;
199767f8919635c4928607450d9e0abb932109ceToomas Soome data[3] = (addr_lo & 0xff000000) >> 24;
199767f8919635c4928607450d9e0abb932109ceToomas Soome data[4] = (addr_hi & 0x0000000ff);
199767f8919635c4928607450d9e0abb932109ceToomas Soome data[5] = (addr_hi & 0x00000ff00) >> 8;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_status_t
199767f8919635c4928607450d9e0abb932109ceToomas Soomehpi_pfc_num_macs_get(hpi_handle_t handle, uint8_t *data)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint8_t addr[6];
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint8_t num = 0;
199767f8919635c4928607450d9e0abb932109ceToomas Soome int i;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome for (i = 0; i < 16; i++) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome (void) hpi_pfc_mac_addr_get_i(handle, addr, i);
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (addr[0] || addr[1] || addr[2] ||
199767f8919635c4928607450d9e0abb932109ceToomas Soome addr[3] || addr[4] || addr[5])
199767f8919635c4928607450d9e0abb932109ceToomas Soome num++;
199767f8919635c4928607450d9e0abb932109ceToomas Soome }
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome *data = num;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome return (HPI_SUCCESS);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}
199767f8919635c4928607450d9e0abb932109ceToomas Soome