FreeBSD/sys/dev/bxe/ecore_sp.c
/**
 * ecore_validate_vlan_mac_move - check if the MOVE command can be executed
 *
 * @sc:		device handle
 * @qo:		quable object to check (source)
 * @elem:	element that needs to be moved
 *
 * Checks that the requested configuration can be moved. If yes and if
 * requested, returns a CAM credit.
 *
 * The 'validate' is run after the 'optimize'.
 */
check if the MOVE command can be executed
@sc:         device handle
@qo:         quable object to check (source)
@elem:       element that needs to be moved

Checks that the requested configuration can be moved. If yes and if
requested, returns a CAM credit.

The 'validate' is run after the 'optimize'.
check if the MOVE command can be executed @sc : device handle @qo : quable object to check ( source ) @elem : element that needs to be moved Checks that the requested configuration can be moved . If yes and if requested returns a CAM credit . The ' validate ' is run after the ' optimize ' .
static inline int ecore_validate_vlan_mac_move(struct bxe_softc *sc,
					       union ecore_qable_obj *qo,
					       struct ecore_exeq_elem *elem)
{
	struct ecore_vlan_mac_obj *src_o = &qo->vlan_mac;
	struct ecore_vlan_mac_obj *dest_o = elem->cmd_data.vlan_mac.target_obj;
	struct ecore_exeq_elem query_elem;
	struct ecore_exe_queue_obj *src_exeq = &src_o->exe_queue;
	struct ecore_exe_queue_obj *dest_exeq = &dest_o->exe_queue;
	if (!src_o->check_move(sc, src_o, dest_o,
			       &elem->cmd_data.vlan_mac.u)) {
		ECORE_MSG(sc, "MOVE command is not allowed considering current registry state\n");
		return ECORE_INVAL;
	}
	ECORE_MEMCPY(&query_elem, elem, sizeof(query_elem));
	query_elem.cmd_data.vlan_mac.cmd = ECORE_VLAN_MAC_DEL;
	if (src_exeq->get(src_exeq, &query_elem)) {
		ECORE_ERR("There is a pending DEL command on the source queue already\n");
		return ECORE_INVAL;
	}
	if (src_exeq->get(src_exeq, elem)) {
		ECORE_MSG(sc, "There is a pending MOVE command already\n");
		return ECORE_EXISTS;
	}
	query_elem.cmd_data.vlan_mac.cmd = ECORE_VLAN_MAC_ADD;
	if (dest_exeq->get(dest_exeq, &query_elem)) {
		ECORE_ERR("There is a pending ADD command on the destination queue already\n");
		return ECORE_INVAL;
	}
	if (!(ECORE_TEST_BIT(ECORE_DONT_CONSUME_CAM_CREDIT_DEST,
			     &elem->cmd_data.vlan_mac.vlan_mac_flags) ||
	    dest_o->get_credit(dest_o)))
		return ECORE_INVAL;
	if (!(ECORE_TEST_BIT(ECORE_DONT_CONSUME_CAM_CREDIT,
			     &elem->cmd_data.vlan_mac.vlan_mac_flags) ||
	    src_o->put_credit(src_o))) {
		dest_o->put_credit(dest_o);
		return ECORE_INVAL;
	}
	return ECORE_SUCCESS;
}
static inline int ecore_validate_vlan_mac_move ( struct bxe_softc * sc , union ecore_qable_obj * qo , struct ecore_exeq_elem * elem ) { struct ecore_vlan_mac_obj * src_o = & qo -> vlan_mac ; struct ecore_vlan_mac_obj * dest_o = elem -> cmd_data . vlan_mac . target_obj ; struct ecore_exeq_elem query_elem ; struct ecore_exe_queue_obj * src_exeq = & src_o -> exe_queue ; struct ecore_exe_queue_obj * dest_exeq = & dest_o -> exe_queue ; if ( ! src_o -> check_move ( sc , src_o , dest_o , & elem -> cmd_data . vlan_mac . u ) ) { ECORE_MSG ( sc , " \n " ) ; return ECORE_INVAL ; } ECORE_MEMCPY ( & query_elem , elem , sizeof ( query_elem ) ) ; query_elem . cmd_data . vlan_mac . cmd = ECORE_VLAN_MAC_DEL ; if ( src_exeq -> get ( src_exeq , & query_elem ) ) { ECORE_ERR ( " \n " ) ; return ECORE_INVAL ; } if ( src_exeq -> get ( src_exeq , elem ) ) { ECORE_MSG ( sc , " \n " ) ; return ECORE_EXISTS ; } query_elem . cmd_data . vlan_mac . cmd = ECORE_VLAN_MAC_ADD ; if ( dest_exeq -> get ( dest_exeq , & query_elem ) ) { ECORE_ERR ( " \n " ) ; return ECORE_INVAL ; } if ( ! ( ECORE_TEST_BIT ( ECORE_DONT_CONSUME_CAM_CREDIT_DEST , & elem -> cmd_data . vlan_mac . vlan_mac_flags ) || dest_o -> get_credit ( dest_o ) ) ) return ECORE_INVAL ; if ( ! ( ECORE_TEST_BIT ( ECORE_DONT_CONSUME_CAM_CREDIT , & elem -> cmd_data . vlan_mac . vlan_mac_flags ) || src_o -> put_credit ( src_o ) ) ) { dest_o -> put_credit ( dest_o ) ; return ECORE_INVAL ; } return ECORE_SUCCESS ; }
ecore_validate_vlan_mac_move - check if the MOVE command can be executed
 @sc:         device handle
 @qo:         quable object to check (source)
 @elem:       element that needs to be moved
ecore_validate_vlan_mac_move - check if the MOVE command can be executed @sc : device handle @qo : quable object to check ( source ) @elem : element that needs to be moved
/* Check if we can perform this operation based on the current registry
	 * state.
	 */ /* Check if there is an already pending DEL or MOVE command for the
	 * source object or ADD command for a destination object. Return an
	 * error if so.
	 */ /* Check DEL on source */ /* Check MOVE on source */ /* Check ADD on destination */ /* Consume the credit if not requested not to */ /* return the credit taken from dest... */